Skip to content

Commit

Permalink
Make GetDatabaseValues call IgnoreQueryFilters()
Browse files Browse the repository at this point in the history
Fixes #8883
  • Loading branch information
AndriySvyryd committed Jun 27, 2017
1 parent e6cd7e6 commit 015d222
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/EFCore.Specification.Tests/Query/FiltersInheritanceTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,30 @@ public virtual void Can_use_of_type_kiwi()
}
}

[Fact]
public virtual void Can_use_derived_set()
{
using (var context = CreateContext())
{
var eagles = context.Set<Eagle>().ToList();

Assert.Equal(0, eagles.Count);
Assert.Equal(0, context.ChangeTracker.Entries().Count());
}
}

[Fact]
public virtual void Can_use_IgnoreQueryFilters_and_GetDatabaseValues()
{
using (var context = CreateContext())
{
var eagle = context.Set<Eagle>().IgnoreQueryFilters().Single();

Assert.Equal(1, context.ChangeTracker.Entries().Count());
Assert.NotNull(context.Entry(eagle).GetDatabaseValues());
}
}

protected InheritanceContext CreateContext() => Fixture.CreateContext(TestStore);

protected FiltersInheritanceTestBase(TFixture fixture)
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore/Internal/EntityFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private IQueryable<object[]> GetDatabaseValuesQuery(InternalEntityEntry entry)
}
}

return _queryRoot.AsNoTracking()
return _queryRoot.AsNoTracking().IgnoreQueryFilters()
.Where(BuildObjectLambda(properties, new ValueBuffer(keyValues)))
.Select(BuildProjection(entityType));
}
Expand Down

0 comments on commit 015d222

Please sign in to comment.