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

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

Contains

Retrieve all records from the Books table that contains "Agriculture" in their Industry name.

C#
コードのコピー
var histories = from p in context.Books
                where p.Industry_name.Contains("Agriculture") //Agricultureを含むIndustry名を表示するには、Containsを使用します。
                select p;
Count

Count all entities that match a given criterion.

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

Select records from the table SampleCSV that belong to Year equal to 2011.

C#
コードのコピー
var histories = from p in db.SampleCSV
                where p.Year== 2011
                select p;
Limit

Select first 2 records.

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

Sort records form the table SampleCSV by Year in descending order.

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

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

C#
コードのコピー
var sampleTable = context.SampleCsvs.AsEnumerable();
var querySample = from b in sampleTable
                  group b by b.Age into newGroup
                  orderby newGroup.Key descending
                  select newGroup;