File tree Expand file tree Collapse file tree 2 files changed +46
-1
lines changed
src/EFCore/Query/Internal
test/EFCore.Specification.Tests/Query Expand file tree Collapse file tree 2 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,9 @@ public class ExpressionTreeFuncletizer : ExpressionVisitor
106106 private static readonly bool UseOldBehavior35152 =
107107 AppContext . TryGetSwitch ( "Microsoft.EntityFrameworkCore.Issue35152" , out var enabled35152 ) && enabled35152 ;
108108
109+ private static readonly bool UseOldBehavior35111 =
110+ AppContext . TryGetSwitch ( "Microsoft.EntityFrameworkCore.Issue35111" , out var enabled35111 ) && enabled35111 ;
111+
109112 private static readonly MethodInfo ReadOnlyCollectionIndexerGetter = typeof ( ReadOnlyCollection < Expression > ) . GetProperties ( )
110113 . Single ( p => p . GetIndexParameters ( ) is { Length : 1 } indexParameters && indexParameters [ 0 ] . ParameterType == typeof ( int ) ) . GetMethod ! ;
111114
@@ -552,7 +555,11 @@ protected override Expression VisitConditional(ConditionalExpression conditional
552555 goto case StateType . ContainsEvaluatable ;
553556
554557 case StateType . ContainsEvaluatable :
555- // The case where the test is evaluatable has been handled above
558+ if ( testState . IsEvaluatable )
559+ {
560+ test = UseOldBehavior35111 ? test : ProcessEvaluatableRoot ( test , ref testState ) ;
561+ }
562+
556563 if ( ifTrueState . IsEvaluatable )
557564 {
558565 ifTrue = ProcessEvaluatableRoot ( ifTrue , ref ifTrueState ) ;
Original file line number Diff line number Diff line change @@ -730,4 +730,42 @@ public class ChildFilter2
730730 }
731731
732732 #endregion
733+
734+ #region 35111
735+
736+ [ ConditionalTheory ]
737+ [ MemberData ( nameof ( IsAsyncData ) ) ]
738+ public virtual async Task Query_filter_with_context_accessor_with_constant ( bool async )
739+ {
740+ var contextFactory = await InitializeAsync < Context35111 > ( ) ;
741+ using var context = contextFactory . CreateContext ( ) ;
742+
743+ var data = async
744+ ? await context . Set < FooBar35111 > ( ) . ToListAsync ( )
745+ : context . Set < FooBar35111 > ( ) . ToList ( ) ;
746+ }
747+
748+ protected class Context35111 ( DbContextOptions options ) : DbContext ( options )
749+ {
750+ public int Foo { get ; set ; }
751+ public long ? Bar { get ; set ; }
752+ public List < long > Baz { get ; set ; }
753+
754+ protected override void OnModelCreating ( ModelBuilder modelBuilder )
755+ {
756+ modelBuilder . Entity < FooBar35111 > ( )
757+ . HasQueryFilter ( e =>
758+ Foo == 1
759+ ? Baz . Contains ( e . Bar )
760+ : e . Bar == Bar ) ;
761+ }
762+ }
763+
764+ public class FooBar35111
765+ {
766+ public long Id { get ; set ; }
767+ public long Bar { get ; set ; }
768+ }
769+
770+ #endregion
733771}
You can’t perform that action at this time.
0 commit comments