Open brunolau opened 4 years ago
@brunolau, sorry such queries are not supported. I think i have to throw more informative exception.
You are trying to select grouped items - this is not transleable to SQL. Add AsEnumerable()
before grouping. But this also will not help if you use associations after AsEnumerable(). They has to be Included.
var query = db.ACL_ItemTicketDate.ToLinqToDB()
.Where(p => p.Id < 1000)
.AsEnumerable()
.GroupBy(p => p.ACL_Item)
.Select(p => new
{
AclItemId = p.Key.Id,
AclItemName = p.Key.Name,
TotalEntryCount = p.Key.ACL_Entries.Sum(ec => ec.EntriesCount),
TotalEntryAllowed = p.Key.ACL_ItemTicketDates.Select(at => new
{
EntryCount = at.EntryCount
}).ToList()
});
Anyway, this query can be optimized if you introduce Window Functions.
@sdanyliv I undestand this might not be supported by the actual version, what I however wanted to point out is that the query did work on prior versions [Linq2Db 2.9.6 + linq2db.EntityFrameworkCore 1.7.1]. See attached project with downgraded package dependencies
It works, but it has N+1 query problem. I'll check maybe i can reuse old functionality in this case.
I'm facing regression on following code path, I receive crashes with null reference exception. The code worked fine with L2DB 2.xx + EF Core provider 2.xx
I'm attaching a sample repro for the problem CrashRep.zip
Sample code goes like this:
And the crash stack trace like this: