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 b4c014b
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)
{
readonly int _foo;

Check failure on line 752 in test/EFCore.Specification.Tests/Query/AdHocQueryFiltersQueryTestBase.cs

View check run for this annotation

Azure Pipelines / efcore-ci (Build Linux)

test/EFCore.Specification.Tests/Query/AdHocQueryFiltersQueryTestBase.cs#L752

test/EFCore.Specification.Tests/Query/AdHocQueryFiltersQueryTestBase.cs(752,22): error CS0649: (NETCORE_ENGINEERING_TELEMETRY=Build) Field 'AdHocQueryFiltersQueryTestBase.Context35111._foo' is never assigned to, and will always have its default value 0
readonly long? _bar;

Check failure on line 753 in test/EFCore.Specification.Tests/Query/AdHocQueryFiltersQueryTestBase.cs

View check run for this annotation

Azure Pipelines / efcore-ci (Build Linux)

test/EFCore.Specification.Tests/Query/AdHocQueryFiltersQueryTestBase.cs#L753

test/EFCore.Specification.Tests/Query/AdHocQueryFiltersQueryTestBase.cs(753,24): error CS0649: (NETCORE_ENGINEERING_TELEMETRY=Build) Field 'AdHocQueryFiltersQueryTestBase.Context35111._bar' is never assigned to, and will always have its default value
readonly List<long> _baz;

Check failure on line 754 in test/EFCore.Specification.Tests/Query/AdHocQueryFiltersQueryTestBase.cs

View check run for this annotation

Azure Pipelines / efcore-ci (Build Linux)

test/EFCore.Specification.Tests/Query/AdHocQueryFiltersQueryTestBase.cs#L754

test/EFCore.Specification.Tests/Query/AdHocQueryFiltersQueryTestBase.cs(754,29): error CS0649: (NETCORE_ENGINEERING_TELEMETRY=Build) Field 'AdHocQueryFiltersQueryTestBase.Context35111._baz' is never assigned to, and will always have its default value null

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 b4c014b

Please sign in to comment.