-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception using LazyLoading When sharing same .Net Type among multiple owned types #11945
Comments
Notes for triage: There are multiple things going on here--I wrote tests for what I found--see below.
Test code for private static void VerifyBlogs(List<Blog> blogs)
{
Assert.Equal(3, blogs.Count);
for (var i = 0; i < 3; i++)
{
Assert.Equal($"firstNameReader{i}", blogs[i].Reader.FirstName);
Assert.Equal($"lastNameReader{i}", blogs[i].Reader.LastName);
Assert.Equal($"firstNameWriter{i}", blogs[i].Writer.FirstName);
Assert.Equal($"lastNameWriter{i}", blogs[i].Writer.LastName);
Assert.Equal($"127.0.0.{i + 1}", blogs[i].Host.HostName);
}
}
[Fact]
public virtual void Lazy_loading_finds_correct_entity_type_with_multiple_queries()
{
using (var context = CreateContext(lazyLoadingEnabled: true))
{
var blogs = context.Set<Blog>().Where(_ => true);
VerifyBlogs(blogs.ToList().OrderBy(e => e.Host.HostName).ToList());
Assert.Equal(12, context.ChangeTracker.Entries().Count());
VerifyBlogs(blogs.ToList().OrderBy(e => e.Host.HostName).ToList());
Assert.Equal(12, context.ChangeTracker.Entries().Count());
}
}
[Fact]
public virtual void Lazy_loading_finds_correct_entity_type_with_opaque_predicate_and_multiple_queries()
{
using (var context = CreateContext(lazyLoadingEnabled: true))
{
Func<Blog, bool> opaquePredicate = _ => true;
var blogs = context.Set<Blog>().Where(opaquePredicate);
VerifyBlogs(blogs.ToList().OrderBy(e => e.Host.HostName).ToList());
Assert.Equal(12, context.ChangeTracker.Entries().Count());
VerifyBlogs(blogs.ToList().OrderBy(e => e.Host.HostName).ToList());
Assert.Equal(12, context.ChangeTracker.Entries().Count());
}
}
[Fact]
public virtual void Lazy_loading_finds_correct_entity_type_with_multiple_queries_using_Count()
{
using (var context = CreateContext(lazyLoadingEnabled: true))
{
var blogs = context.Set<Blog>().Where(_ => true);
Assert.Equal(3, blogs.Count());
Assert.Empty(context.ChangeTracker.Entries());
Assert.Equal(3, blogs.Count());
Assert.Empty(context.ChangeTracker.Entries());
}
}
[Fact]
public virtual void Lazy_loading_finds_correct_entity_type_with_opaque_predicate_and_multiple_queries_using_Count()
{
using (var context = CreateContext(lazyLoadingEnabled: true))
{
Func<Blog, bool> opaquePredicate = _ => true;
var blogs = context.Set<Blog>().Where(opaquePredicate);
Assert.Equal(3, blogs.Count());
Assert.Empty(context.ChangeTracker.Entries());
Assert.Equal(3, blogs.Count());
Assert.Empty(context.ChangeTracker.Entries());
}
} |
I'm having the same issue.
Please see my sample code @ https://github.com/amilarox1/OwnedTypes Further technical details |
@amilarox1 Your case has a completely different stack trace, indicating that it is not the same root cause. Can you please file a new issue? |
Created new issue #11972 |
Describe what is not working as expected.
I am using postgres and I have lazy loading enabled. I have one class with 2 owned properties which are from the same .NET type (analogue to this: https://docs.microsoft.com/en-us/ef/core/modeling/owned-entities#sharing-the-same-net-type-among-multiple-owned-types). Doing Count() on the set results in not being ably to Skip(...).Take(...)
If you are seeing an exception, include the full exceptions details (message and stack trace).
Steps to reproduce
Further technical details
EF Core version: 2.1.0-rc1
Database Provider: Npgsql 2.1.0-rc1
Operating system: Win10
IDE: Visual Studio 2017 15.6.6
The text was updated successfully, but these errors were encountered: