I find that the GetAllIncluding is not stable
The below is the code that i link all related object out
but from my screenshot, you can see sometimes it can map to the object ProductApproval.Approver1 and sometimes i can't.
Is it because my apsnetboilerplate framework is on version 2.0.2?
should i update to the latest aspnetboilerplate framework?
private IEnumerable<Product> GetProduct(FilterInput input)
{
var output = from p in
(_productRepo.GetAllIncluding(
p => p.Colour,
p => p.Unit,
p => p.Serie,
p => p.Brand,
p => p.Supplier,
p => p.ProductCategory1,
p => p.ProductCategory2,
p => p.ProductCategory3,
p => p.ProductCategory4,
p => p.MinQuantities,
p => p.ProductApprovals,
p => p.CreatorUser,
p => p.CreatorUser.Company
).ToList())
where Filter.FilterUtil.FilterForGetProduct(p, input)
select p;
return output;
}
5 Answer(s)
-
0
GetAllIncluding is single-level. To include nested relationships, add using Microsoft.EntityFrameworkCore; and do:
var output = from p in (_productRepo.GetAllIncluding( // ... // p => p.ProductApprovals // Comment out this line // ... ).Include(p => p.ProductApprovals) // Include relationship .ThenInclude(pa => pa.Approver1) // ThenInclude nested relationship .ToList()) where Filter.FilterUtil.FilterForGetProduct(p, input) select p;
-
0
-
0
Hi Aaron
I have changed the the below LINQ
but it seems the output still cannot get the ProductApprovals object
I have attached the Domain Entity for your reference too. please advise. Thanks a lot
var output = from p in (_productRepo.GetAllIncluding( p => p.Colour, p => p.Unit, p => p.Serie, p => p.Brand, p => p.Supplier, p => p.ProductCategory1, p => p.ProductCategory2, p => p.ProductCategory3, p => p.ProductCategory4, p => p.MinQuantities, p => p.CreatorUser, p => p.CreatorUser.Company ).Include(p => p.ProductApprovals) // Include relationship .ThenInclude(pa => pa.Approver1) // ThenInclude nested relationship .ToList()) where Filter.FilterUtil.FilterForGetProduct(p, input) select p;
-
0
Nested include <a class="postlink" href="https://stackoverflow.com/questions/15764572/ef-linq-include-multiple-and-nested-entities">https://stackoverflow.com/questions/157 ... d-entities</a>
-
0
Remove .First() — you may get an "error" from Intellisense, but it should still compile. See discussion (aspnet/EntityFrameworkCore#6560) and cause (dotnet/roslyn#8237).