C
C#3mo ago
Krille

✅ Need some help debugging EF Core db query

I am trying to get some information from the database. I am running this query:
var ordersInLastThirtyDays = await _dbContext.Orders
.AsSplitQuery()
.IgnorePending()
.Where(x => x.InternalPropertyId == request.InternalPropertyId && x.UserId == _auth.GetCurrentUserId())
.Include(x => x.Customer)
.Include(x => x.RentableReservations)
.ToListAsync();
var ordersInLastThirtyDays = await _dbContext.Orders
.AsSplitQuery()
.IgnorePending()
.Where(x => x.InternalPropertyId == request.InternalPropertyId && x.UserId == _auth.GetCurrentUserId())
.Include(x => x.Customer)
.Include(x => x.RentableReservations)
.ToListAsync();
I've located the problem to the RentableReservations table, but it doesn't even contain any null values. How do I debug this error further?
No description
2 Replies
boiled goose
boiled goose3mo ago
just to be clear, is the data in the database coherent/correct and what you expect to be?
Krille
Krille3mo ago
Sorry for the late response. The problem was that I had changed the entities from being owned to separate tables. Therefore the reference had become null. That’s why I couldn’t find any null values in the database. I fixed the problem by adding the references again