File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed
src/EFCore/Query/Internal
test/EFCore.Specification.Tests/Query Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -539,7 +539,11 @@ protected override Expression VisitConditional(ConditionalExpression conditional
539539 goto case StateType . ContainsEvaluatable ;
540540
541541 case StateType . ContainsEvaluatable :
542- // The case where the test is evaluatable has been handled above
542+ if ( testState . IsEvaluatable )
543+ {
544+ test = ProcessEvaluatableRoot ( test , ref testState ) ;
545+ }
546+
543547 if ( ifTrueState . IsEvaluatable )
544548 {
545549 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