Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
cincuranet committed Nov 29, 2024
1 parent d1e1dfa commit b626ad4
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using static Microsoft.EntityFrameworkCore.DbLoggerCategory;

namespace Microsoft.EntityFrameworkCore.Query;

#nullable disable
Expand Down Expand Up @@ -730,4 +732,44 @@ public class ChildFilter2
}

#endregion

#region 35111

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual async Task Query_filter_with_context_accessor_with_constant(bool async)
{
var contextFactory = await InitializeAsync<Context35111>();
using var context = contextFactory.CreateContext();

var data = async
? await context.FooBars.ToListAsync()
: context.FooBars.ToList();
}

protected class Context35111(DbContextOptions options) : DbContext(options)
{
public int Foo { get; set; }
public long? Bar { get; set; }
public List<long> Baz { get; set; }

public DbSet<FooBar> FooBars { get; set; }

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<FooBar>()
.HasQueryFilter(e =>
Foo == 1
? Baz.Contains(e.Bar)
: e.Bar == Bar);
}
}

public class FooBar
{
public long Id { get; set; }
public long Bar { get; set; }
}

#endregion
}

0 comments on commit b626ad4

Please sign in to comment.