Is there a way to keep efficient counting on Entity Framework? Please, any help would be appreciated.
I am trying to count rows on an EF query, but the count goes in timeout, nevertheless the query itself it is ok.
Tried with .AsNoTracking() also.
Example:
ObjGetIndexedViewResult.TotRecord = listDocuments.AsNoTracking()
.Select(x => new { x.id })
.Count();
sorry for bothering ya, just found the solution!
with .Distinct().
ObjGetIndexedViewResult.TotRecord = listDocuments.Distinct().AsNoTracking().Select(x => new { x.id }).Count();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With