Skip and Take for Paginated Queries
Passing variables directly to the skip and take functions of Entity Framework results in them being inserted in to the query as literals. This mean a new query is created on every execution. Switch to using lambda expressions and Entity Framework will now recognise your Skip and Take values as parameters that can be passed to a compiled query. So the query doesn't need to be recompiled each time.
query.Skip(() => recordsToSkip).Take(() => pageLength)