Kopīgot, izmantojot


Build queries with LINQ (.NET language-integrated query)

 

Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

You can use .NET Language-Integrated Query (LINQ) to write queries in Microsoft Dynamics 365 (online & on-premises). You can use the OrganizationServiceContext class or a deriving class created by the CrmSvcUtil tool to write LINQ queries that access the SOAP endpoint (Organization.svc). The OrganizationServiceContext class contains an underlying LINQ query provider that translates LINQ queries from Microsoft Visual C# or Microsoft Visual Basic .NET syntax into the query API used by Microsoft Dynamics 365.

When you use early-bound programming classes you can generate a class derived from the OrganizationServiceContext class if you specify the name of the class using the servicecontextname parameter when using the Code Generation Tool (CrmSvcUtil.exe). Use of this class allows for referencing an IQueryable entity set using the pattern <entity schema name>+Set, for example AccountSet to reference the collection of Account entity records. All samples in the Microsoft Dynamics 365 SDK use ServiceContext as the name for this class but your code may use a different name. More information:  Create early bound entity classes with the code generation tool (CrmSvcUtil.exe)

In This Section

Use LINQ to construct a query

Use late-bound entity class with a LINQ query

Order results using entity attributes with LINQ

Order results using entity attributes with LINQ

Page large result sets with LINQ

LINQ query examples

Sample: Create a LINQ query

Sample: Complex LINQ queries

Sample: Retrieve multiple with condition operators using LINQ

Sample: More LINQ query examples

Sample: Create a LINQ query with late binding

Microsoft Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright