You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you're using Entity Framework Core, you can switch to using lambda expressions with Skip and Take. The benefit here is that LINQ+EF will recognize your Skip and Take values as parameters that can be passed to a compiled query.
LINQ for EF will compile your query once and just re-execute it on each request, passing the new values for pos and size. It's a trivial change to your syntax but it can shave 10 percent off the time it takes your repeated query to run.
privatevoidInitSubset(IOrderedQueryable<T>superset,intpageNumber,intpageSize){varitemsToSkip=(pageNumber-1)*pageSize;// add items to internal listvaritems=superset.Skip(()=>itemsToSkip).Take(()=>pageSize).ToList();Subset.AddRange(items);}