分頁 LINQ 大型結果集
發行︰ 2017年1月
適用於: Dynamics 365 (online)、Dynamics 365 (on-premises)、Dynamics CRM 2016、Dynamics CRM Online
在 Microsoft Dynamics 365 (線上和內部部署),使用 Take 和 Skip 運算子,您可以分頁大型 .NET Language-Integrated Query (LINQ) 查詢的結果。Take 運算子擷取指定的結果數目,而 Skip 運算子略過指定的結果數目。
LINQ 分頁範例
下列範例顯示如何使用 Take 和 Skip 運算子,分頁 LINQ 查詢的結果:
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);
}
' Retrieve records with Skip/Take record paging. Setting a page size
' can help you manage your Skip and Take calls, since Skip must be
' passed a multiple of Take's parameter value.
Dim pageSize As Integer = 5
Dim accountsByPage = ( _
From a In svcContext.CreateQuery(Of Account)() _
Select New Account With {.Name = a.Name})
Console.WriteLine("Skip 10 accounts, then Take 5 accounts")
Console.WriteLine("======================================")
For Each a In accountsByPage.Skip(2 * pageSize).Take(pageSize)
Console.WriteLine(a.Name)
Next a
Console.WriteLine()
Console.WriteLine("<End of Listing>")
Console.WriteLine()
另請參閱
建立與 LINQ (.NET Language Integrated Query) 的查詢
LINQ 查詢範例
Microsoft Dynamics 365
© 2017 Microsoft. 著作權所有,並保留一切權利。 著作權