DataConnector
LINQ クエリ
ADO.NET provider for Dynamics 365 Sales > LINQ クエリ

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

Contains

Retrieve records from the Contracts table where the title contain "con".

C#
コードのコピー
var records = from p in context.Contracts
              where p.Title.Contains("con")
              select p;
Count

Count all entities that match a given criterion.

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

Select records from the Contracts table that belong to Title equal to "AGR-04".

C#
コードのコピー
var records = from p in context.Contracts
              where p.Title == "AGR-04"
              select p;
Group by

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

C#
コードのコピー
var accountTable = context.Accounts.AsEnumerable();
var queryAccount = from b in accountTable
                   group b by b.Accountnumber into newGroup
                   orderby newGroup.Key descending
                   select newGroup;
Join

Join the tables Contracts and Accounts.

C#
コードのコピー
var records = (from c in context.Contracts.Take(10)
              from a in context.Accounts.Take(10)
              select new { c, a }
              ).Take(20);
Limit

Select first 10 records.

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

Sort records by Name in descending order.

C#
コードのコピー
var records = (from Accounts in context.Accounts.Take(10)
              orderby Accounts.Name descending
              select Accounts
              ).Take(10);