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

Note

Unsure about entity vs. table? See Developers: Understand terminology in Microsoft Dataverse.

You can use .NET Language-Integrated Query (LINQ) to write queries for Microsoft Dataverse. You can use the OrganizationServiceContext class or a deriving class created by the CrmSvcUtil tool to write LINQ queries that access the 2011 SOAP endpoint's Organization service. The OrganizationServiceContext class contains an underlying LINQ query provider that translates LINQ queries from Visual C# or Visual Basic .NET syntax into the query API used by Dataverse.

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 table set using the pattern <table schema name>+Set, for example AccountSet to reference the collection of Account table rows. All samples in the Dataverse Web Services, use ServiceContext as the name for this class but your code may use a different name. More information: Generate early-bound classes for the Organization service).

See Also

Use LINQ to construct a query
Use late-bound Entity class with a LINQ Query
Use table lookup columns with LINQ
LINQ query examples
Generate early-bound classes for the Organization service