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

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

Contains

Retrieve records from the Books table where the AuthorFirstName contains the letter"A".

C#
コードのコピー
var histories = from p in db.Books
                where p.AuthorFirstName.Contains("A") //Contains を使用して、名に「a」を含む著者名を表示します。 
                select p;
Count

Count all entities that match a given criterion.

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

Select records from the Books table that belong to Genre equal to "autobiography".

C#
コードのコピー
var histories = from p in db.Books
                where p.Genre== "autobiography"
                select p;
Limit

Select first 2 records.

C#
コードのコピー
var histories = (from p in db.Books
                select p).Take(2); //履歴を2つ取得します。
Order By

Sort records by Title in descending order.

C#
コードのコピー
var histories = (from p in db.Books
                orderby p.Title descending //Order Byの実装
                select p).Take(2); //履歴を2つ取得します。
Group By

Group records from the Books table based on the Title property. The groups are then ordered in descending order based on the Title.

C#
コードのコピー
var booksTable = context.Books.AsEnumerable();
var queryBooks = from b in booksTable
                 group b by b.Title into newGroup
                 orderby newGroup.Key descending
                 select newGroup;