File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
test/EFCore.Specification.Tests/Query Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 11// Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33
4+ using static Microsoft . EntityFrameworkCore . DbLoggerCategory ;
5+
46namespace Microsoft . EntityFrameworkCore . Query ;
57
68#nullable disable
@@ -730,4 +732,44 @@ public class ChildFilter2
730732 }
731733
732734 #endregion
735+
736+ #region 35111
737+
738+ [ ConditionalTheory ]
739+ [ MemberData ( nameof ( IsAsyncData ) ) ]
740+ public virtual async Task Query_filter_with_context_accessor_with_constant ( bool async )
741+ {
742+ var contextFactory = await InitializeAsync < Context35111 > ( ) ;
743+ using var context = contextFactory . CreateContext ( ) ;
744+
745+ var data = async
746+ ? await context . FooBars . ToListAsync ( )
747+ : context . FooBars . ToList ( ) ;
748+ }
749+
750+ protected class Context35111 ( DbContextOptions options ) : DbContext ( options )
751+ {
752+ readonly int _foo ;
753+ readonly long ? _bar ;
754+ readonly List < long > _baz ;
755+
756+ public DbSet < FooBar > FooBars { get ; set ; }
757+
758+ protected override void OnModelCreating ( ModelBuilder modelBuilder )
759+ {
760+ modelBuilder . Entity < FooBar > ( )
761+ . HasQueryFilter ( e =>
762+ _foo == 1
763+ ? _baz . Contains ( e . Bar )
764+ : e . Bar == _bar ) ;
765+ }
766+ }
767+
768+ public class FooBar
769+ {
770+ public long Id { get ; set ; }
771+ public long Bar { get ; set ; }
772+ }
773+
774+ #endregion
733775}
You can’t perform that action at this time.
0 commit comments