LINQ による大量の結果セットのページング

 

公開日: 2017年1月

対象: Dynamics 365 (online)、Dynamics 365 (on-premises)、Dynamics CRM 2016、Dynamics CRM Online

Microsoft Dynamics 365 (オンラインおよび設置型) では、大量の .NET 統合言語クエリ (LINQ) クエリの結果を、Take 演算子と Skip 演算子を使用してページングできます。Take 演算子は指定された数の結果を取得し、Skip 演算子は指定された数の結果をスキップします。

LINQ ページングの例

以下の例は、LINQ クエリの結果を TakeSkip 演算子を使用してページングする方法を示します。


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 統合言語クエリ) を使用してクエリを作成する
LINQ クエリの例

Microsoft Dynamics 365

© 2017 Microsoft. All rights reserved. 著作権