Dynamics CRM 2016 – Querying Data with QueryExpression.
QueryExpression is useful in scenarios where you want to return multiple entities that match a certain criteria. It lets you specify which fields you want to have returned (from the specified entity type or any related entity) as part of the query result in order to improve performance. Developers can also control the order in which records are returned.
To Know the power of QueryExpression, let’s take a look at a few examples:
Example 1 – Simple query with two conditions for a single entity
Scenario: Retrieve the First Name, Last Name, and Email Address for Contacts that have the Job Title field set and live in Auckland city
Example 2 – Complex query with multiple conditions across two related entities
Scenario: Retrieve the First Name, Last Name, and Email Address for Contacts that are “Sales Managers” and the Parent Customer is based in Auckland or Wellington city
Example 3 – Simple query with OrderExpression
Scenario: Retrieve all Accounts in the system and order by the date created (most recent first)