Entity Framework Paging

entity-framework

Question

Database paging in Entity Framework is often carried out in the way shown below using LINQ to Entities:

int totalRecords = EntityContext.Context.UserSet.Count;
var list     = EntityContext.Context.UserSet
                 .Skip(startingRecordNumber)
                 .Take(pageSize)
                 .ToList();

This leads to calls to the TWO database.

Tell me how to make only one database call, please.

I'm grateful.

1
31
6/26/2009 3:39:23 PM

Popular Answer

Why is it bad to make two calls? They are brief and concise questions. Many tiny queries may be supported by databases.

You won't get much benefit from designing a complicated solution to do a single query for paging.

36
8/30/2010 2:50:58 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow