Answer the question
In order to leave comments, you need to log in
How to optimize IPaginatedList?
Hi all. Faced such a problem. Used on EF 6 + IPaginationList project. The implementation has a field that receives the number of records Count(). The request hangs on this line of code.
public IPaginatedList<T> Apply<T>(IEnumerable<T> source)
{
var totalRecords = source.Count();
.....
Answer the question
In order to leave comments, you need to log in
You have an IEnumerable method as input, which causes C# to enumerate the data source (SELECT * FROM source).
To instead generate a request for a quantity, you need to receive an IQueryable as an input. Then a query like SELECT count(*) FROM source will be generated.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question