Paging (edit)

Linq

https://stackoverflow.com/questions/17047192/entityframework-do-paging-on-a-query-with-a-join

var data = (from v in context.Vehicles
         join va in context.VehicleAttributes on v.VehicleId equals va.VehicleId into vAttributes
         from vehicleAttributes in vAttributes.DefaultIfEmpty()
         where v.FleetId == fleetId
         select new { v, vehicleAttributes })
         .OrderBy(p => p.v.FleetId)
         .Skip(10 * (page - 1))
         .Take(10)
         .ToList();

Paging a Query with SQL Server

https://social.technet.microsoft.com/wiki/contents/articles/23811.paging-a-query-with-sql-server.aspx

Paging of Large Resultsets in ASP.NET

https://www.codeproject.com/Articles/6936/Paging-of-Large-Resultsets-in-ASP-NET

What is the best way to paginate results in SQL Server

Getting the total number of results and paginating are two different operations. For the sake of this example, let's assume that the query you're dealing with is

SELECT * FROM Orders WHERE OrderDate >= '1980-01-01' ORDER BY OrderDate

In this case, you would determine the total number of results using:

SELECT COUNT(*) FROM Orders WHERE OrderDate >= '1980-01-01'

...which may seem inefficient, but is actually pretty performant, assuming all indexes etc. are properly set up.

Next, to get actual results back in a paged fashion, the following query would be most efficient:

SELECT  *
FROM    ( SELECT    ROW_NUMBER() OVER ( ORDER BY OrderDate ) AS RowNum, *
          FROM      Orders
          WHERE     OrderDate >= '1980-01-01'
        ) AS RowConstrainedResult
WHERE   RowNum >= 1
    AND RowNum < 20
ORDER BY RowNum

This will return rows 1-19 of the original query. The cool thing here, especially for web apps, is that you don't have to keep any state, except the row numbers to be returned.

https://stackoverflow.com/questions/109232/what-is-the-best-way-to-paginate-results-in-sql-server

SELECT *
FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY CreatedOn ) AS RowNum ,
*
FROM dbo.Project
WHERE CreatedOn >= '1980-01-01'
) AS RowConstrainedResult
WHERE RowNum >= 1
AND RowNum < 20
ORDER BY RowNum;

Tutorial 25: Efficiently Paging Through Large Amounts of Data

https://msdn.microsoft.com/en-us/library/bb445504.aspx