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

LINQ queries demonstrate how to operate and query the OData 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 "A" in their Author name.

C#
コードのコピー
var records = from p in context.Books
              where p.Author.Contains("A")
              select p;
Count

Count all entities that match a given criterion.

C#
コードのコピー
var _count = (from p in context.Books
              select p).Count();
Filter

Select records from the table Books that belong to Location_City equal to Delhi.

C#
コードのコピー
var records = from p in context.Books
              where p.Location_City == "Delhi"
              select p;
Group By

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

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

Cross join between Books and Employees tables.

C#
コードのコピー
var records = from b in context.Books
              from e in context.Employees
              select new { b, e };
Limit

Retrieve the first 10 records from the Books table.

C#
コードのコピー
var records = (from p in context.Books
                   select p).Take(10);
Order By

Sort records form the Books table by Title in descending order.

C#
コードのコピー
var records = from p in context.Books
                      orderby p.Title descending
                      select p;