DataConnector
LINQ クエリ
ADO.NET provider for Kintone > LINQ クエリ

LINQ queries demonstrate how to operate and query the Kintone objects wrapped in an Entity Framework data model. Listed below are some examples of LINQ queries supported by the Entity framework.

Select and Filter

Retrieve records from the Accounts table where the AccountID is "155".

C#
コードのコピー
var records = from p in context.Accounts
              where p.AccountId == "155"
              select p;
Contains

Retrieve records from the Accounts table that contains the letter "A" in the Name column.

C#
コードのコピー
var records = from p in context.Accounts
              where p.Name.Contains("A") //Contains を使用して、名前に A が含まれる名前を表示します。
              select p;
Limit

Retrieve the first 10 records from the Accounts table. This helps to limit display of records.

C#
コードのコピー
var records = (from p in context.Accounts
               select p).Take(10); // レコードを10 件取得します。
Order by

Retrieve the first 10 records from the Accounts table and sort them in descending order based on the Age property.

C#
コードのコピー
var records = (from p in context.Accounts
               orderby p.Age descending//Implementing Order By
               select p).Take(10); // レコードを10 件取得します。
 Count

Count all records that match a given criterion. 

C#
コードのコピー
var _count = (from p in context.Accounts
              select p).Count();//選択されたレコードの数に基づいてクエリをカウントします。
Group By

Group records from the Accounts table based on the Address property.

C#
コードのコピー
var accountsTable = context.Accounts.AsEnumerable();
var queryAccounts = from b in accountsTable
                    group b by b.Address into newGroup
                    orderby newGroup.Key descending
                    select newGroup;
Joins

Cross join between Accounts and Products tables.

C#
コードのコピー
var records = from b in context.Accounts
              from e in context.Products
              select new { b, e };//クロス結合を定義します。