It's a modern and generic data access structure for .NET and Microsoft.EntityFrameworkCore. It supports UnitOfWork, Repository and QueryBuilder patterns. It also includes auto history utilities, multiple databases support with distributed transactions and databases/tables sharding for some database providers.
MIT License
165
stars
25
forks
source link
Include behavior different when using UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking) #18
I've just started trying to implement this library into a project and I'm having trouble getting it to load a one-to-one relationship.
I have a User entity, and I have a Queue entity. There is a single queue/one-to-one for each user, so I have a Queue property on the User entity using the foreign key.
When I attempt to Include the Queue property, unless I have NoTracking set, it isn't populated.
var repository = _unitOfWork.Repository<User>();
var query = repository.SingleResultQuery()
.AndFilter(u => u.UserId == userId)
.Include(src => src.Include(u => u.Queue));
/////.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
var user = await repository.SingleOrDefaultAsync(query);
user.Queue will be null here...
var query = repository.SingleResultQuery()
.AndFilter(u => u.UserId == userId)
.Include(src => src.Include(u => u.Queue));
.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
var user = await repository.SingleOrDefaultAsync(query);
I've just started trying to implement this library into a project and I'm having trouble getting it to load a one-to-one relationship.
I have a User entity, and I have a Queue entity. There is a single queue/one-to-one for each user, so I have a Queue property on the User entity using the foreign key.
When I attempt to Include the Queue property, unless I have NoTracking set, it isn't populated.
user.Queue will be null here...
user.Queue is correctly loaded here....
What am I doing wrong?
Thanks-