I reviewed almost everything online but couldn't get it work in a reasonable time.
Entity Framework Core 3.0 .Include
call is taking 10x more time than calling the individual tables separately and then mapping them in C# code.
I have two tables product
and productimages
, where product productimages is a collection inside product.
Now when I chain the call with .Include
function, it takes forever to get the records form DB:
products = _context.ProductUploadQueue
.Include(x => x.ProductUploadQueueImage)
.Where(x => x.ClientId == clientId && x.PalletId == palletID)
.ToList();
but if I do the same while calling the both tables individually and not chaining the Include call, it speeds up everything:
var g = _context.ProductUploadQueue
.AsNoTracking()
.Where(x => x.ClientId == clientId && x.PalletId == palletID)
.ToList();
var hp = g.Select(x => x.Id);
var y = _context.ProductUploadQueueImage
.Where(x => hp.Contains(x.ProductUploadQueueId))
.ToList();
How can I speed it up?