Page large result sets with LINQ



Often, a CRM consultant has to develop some custom code to work with large result sets, below is an example that it can be found in the SDK using LINQ.

I will do my tests as well to see the best option to use (Linq, QueryExpression and Fetch) in terms of performance and time to develop as well, however below is the LINQexample:

The following example shows how to page the results of a LINQ query by using the Take and Skip operators:


int pageSize = 5; var accountsByPage = (from a in svcContext.AccountSet                       select new Account                       {                        Name = a.Name,                       }); System.Console.WriteLine("Skip 10 accounts, then Take 5 accounts"); System.Console.WriteLine("======================================"); foreach (var a in accountsByPage.Skip(2 * pageSize).Take(pageSize)) {  System.Console.WriteLine(a.Name); }

#CRM2015 #LargeResultSets #Queries

0 views0 comments

Recent Posts

See All