You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: powerapps-docs/developer/common-data-service/org-service/build-queries-with-queryexpression.md
+52-56Lines changed: 52 additions & 56 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: "Build queries with QueryExpression (Common Data Service) | Microsoft Docs"# Intent and product brand in a unique string of 43-59 chars including spaces
3
3
description: "Read how you can use the QueryExpression class to programmatically build a query containing data filters and search conditions that define the scope of a database search"# 115-145 characters including spaces. This abstract displays in the search result.
4
4
ms.custom: ""
5
-
ms.date: 10/31/2018
5
+
ms.date: 06/25/2019
6
6
ms.reviewer: ""
7
7
ms.service: powerapps
8
8
ms.topic: "article"
@@ -17,60 +17,56 @@ search.app:
17
17
---
18
18
# Build queries with QueryExpression
19
19
20
-
In Common Data Service, you can use the <xref:Microsoft.Xrm.Sdk.Query.QueryExpression> class to programmatically build a query containing data filters and search conditions that define the scope of a database search. A query expression is used for single-object searches. For example, you can create a search to return all accounts that match certain search criteria. The <xref:Microsoft.Xrm.Sdk.Query.QueryBase> class is the base class for query expressions. There are two derived classes: <xref:Microsoft.Xrm.Sdk.Query.QueryExpression> and <xref:Microsoft.Xrm.Sdk.Query.QueryByAttribute>. The `QueryExpression` class supports complex queries. The `QueryByAttribute` class is a simple means to search for entities where attributes match specified values.
21
-
22
-
Query expressions are used in methods that retrieve more than one record, such as the <xref:Microsoft.Xrm.Sdk.IOrganizationService>.<xref:Microsoft.Xrm.Sdk.IOrganizationService.RetrieveMultiple*> method, in messages that perform an operation on a result set specified by a query expression, such as <xref:Microsoft.Crm.Sdk.Messages.BulkDeleteRequest> and when the ID for a specific record is not known.
23
-
24
-
In addition, there is a new attribute on the organization entity, `Organization.QuickFindRecordLimitEnabled`. When this `Boolean` attribute is `true`, a limit is imposed on quick find queries. If a user provides search criteria in quick find that is not selective enough, the system detects this and stops the search. This supports a faster form of quick find and can make a big performance difference.
20
+
In Common Data Service, you can use the <xref:Microsoft.Xrm.Sdk.Query.QueryExpression> class to programmatically build a query containing data filters and search conditions that define the scope of a database search. A query expression is used for single-object searches. For example, you can create a search to return all accounts that match certain search criteria. The <xref:Microsoft.Xrm.Sdk.Query.QueryBase> class is the base class for query expressions. There are three derived classes: <xref:Microsoft.Xrm.Sdk.Query.QueryExpression>, <xref:Microsoft.Xrm.Sdk.Query.QueryByAttribute> and <xref:Microsoft.Xrm.Sdk.Query.FetchExpression>. The `QueryExpression` class supports complex queries. The `QueryByAttribute` class is a simple means to search for entities where attributes match specified values.
21
+
22
+
> [!NOTE]
23
+
> The third derived class, `FetchExpression` is used with FetchXML, the proprietary Common Data Service query language, can be used to perform some queries by using XML-based queries. More information: [Use FetchXML to construct a query](../use-fetchxml-construct-query.md)
25
24
25
+
Query expressions are used in methods that retrieve more than one record, such as the <xref:Microsoft.Xrm.Sdk.IOrganizationService>.<xref:Microsoft.Xrm.Sdk.IOrganizationService.RetrieveMultiple*> method, in messages that perform an operation on a result set specified by a query expression, such as <xref:Microsoft.Crm.Sdk.Messages.BulkDeleteRequest> and when the ID for a specific record is not known.
26
+
26
27
> [!WARNING]
27
-
> Don’t retrieve all attributes in a query because of the negative effect on performance. This is particularly true if the query is used as a parameter to an update request. In an update, if all attributes are included this sets all field values, even if they are unchanged, and often triggers cascaded updates to child records.
28
-
29
-
There are two additional ways to create queries to retrieve records from Common Data Service. FetchXML, the proprietary Common Data Service query language, can be used to perform some queries by using XML-based queries. For more information, see [Building Queries with FetchXML](/dynamics365/customer-engagement/developer/org-service/build-queries-fetchxml). You can also use .NET Language-Integrated Query (LINQ) to write queries. More information: [Build Queries with LINQ (.NET Language-Integrated Query)](build-queries-with-linq-net-language-integrated-query.md).
30
-
31
-
To save a query, you can convert it to FetchXML by using the <xref:Microsoft.Crm.Sdk.Messages.QueryExpressionToFetchXmlRequest> and save it as a saved view by using the `userquery` entity.
32
-
33
-
## In This Section
34
-
[Using the QueryByAttribute Class](use-querybyattribute-class.md)
35
-
36
-
[Using the QueryExpression Class](use-queryexpression-class.md)
37
-
38
-
[Using the ColumnSet Class](use-the-columnset-class.md)
39
-
40
-
[Using the ConditionExpression Class](use-conditionexpression-class.md)
41
-
42
-
[Using the FilterExpression Class](use-filterexpression-class.md)
43
-
44
-
[Use a left outer join in QueryExpression to query for records "not in"](use-left-outer-join-queryexpression-query-records-not-in.md)
45
-
46
-
[Testing for a Null Value](/dynamics365/customer-engagement/developer/test-null-value)
47
-
48
-
[Page Large Result Sets with Query Expression and FetchXML](page-large-result-sets-with-queryexpression.md)
49
-
50
-
[Sample: Retrieve With One-To-Many Relationship](/dynamics365/customer-engagement/developer/org-service/sample-retrieve-with-one-to-many-relationship)
51
-
52
-
[Sample: Retrieve Multiple with Query By Attribute](/org-service/samples/retrieve-multiple-querybyattribute-class.md)
53
-
54
-
[Sample: Retrieve Multiple with Query Expression](/org-service/samples/retrieve-multiple-queryexpression-class.md)
55
-
56
-
[Sample: Use QueryExpression with a paging cookie](/dynamics365/customer-engagement/developer/org-service/sample-use-queryexpression-with-a-paging-cookie)
[Sample: Convert queries between Fetch and QueryExpression](/dynamics365/customer-engagement/developer/org-service/sample-convert-queries-fetch-queryexpression)
28
+
> Don’t retrieve all attributes in a query because of the negative effect on performance. This is particularly true if the query is used as a parameter to an update request. In an update, if all attributes are included this sets all field values, even if they are unchanged, and often triggers cascaded updates to child records.
29
+
30
+
To save a query so you can re-use it, you can convert it to FetchXML by using the <xref:Microsoft.Crm.Sdk.Messages.QueryExpressionToFetchXmlRequest> and save it as a saved query. More information: [Saved queries](../saved-queries.md)
31
+
32
+
## Alternatives to QueryExpression
33
+
34
+
There are two additional ways to create queries to retrieve records from Common Data Service.
35
+
36
+
- FetchXML, the proprietary Common Data Service query language, can be used to perform some queries by using XML-based queries. More information: [Use FetchXML to construct a query](../use-fetchxml-construct-query.md).
37
+
- .NET Language-Integrated Query (LINQ). More information: [Build Queries with LINQ (.NET Language-Integrated Query)](build-queries-with-linq-net-language-integrated-query.md).
38
+
39
+
<!-- This doesn't belong here. It should be in model driven app configuration -->
40
+
## Configuration for Quick find
41
+
42
+
In Model-driven apps, there is a Quick Find feature. If a user provides search criteria in quick find that is not selective enough, the system detects this and stops the search. This supports a faster form of quick find and can make a big performance difference. This is controlled by the [Organization entity QuickFindRecordLimitEnabled](/powerapps/developer/common-data-service/reference/entities/organization#BKMK_QuickFindRecordLimitEnabled) attribute. When this `Boolean` attribute value is `true`, a limit is imposed on quick find queries.
43
+
44
+
## In This Section
45
+
46
+
[Using the QueryByAttribute Class](use-querybyattribute-class.md)<br />
47
+
[Using the QueryExpression Class](use-queryexpression-class.md)<br />
48
+
[Using the ColumnSet Class](use-the-columnset-class.md)<br />
49
+
[Using the ConditionExpression Class](use-conditionexpression-class.md)<br />
50
+
[Using the FilterExpression Class](use-filterexpression-class.md)<br />
51
+
[Use a left outer join in QueryExpression to query for records "not in"](use-left-outer-join-queryexpression-query-records-not-in.md)<br />
52
+
[Testing for a Null Value](/dynamics365/customer-engagement/developer/test-null-value)<br />
53
+
[Page Large Result Sets with Query Expression and FetchXML](page-large-result-sets-with-queryexpression.md)<br />
54
+
[Sample: Retrieve With One-To-Many Relationship](/dynamics365/customer-engagement/developer/org-service/sample-retrieve-with-one-to-many-relationship)<br />
55
+
[Sample: Retrieve Multiple with Query By Attribute](/org-service/samples/retrieve-multiple-querybyattribute-class.md)<br />
56
+
[Sample: Retrieve Multiple with Query Expression](/org-service/samples/retrieve-multiple-queryexpression-class.md)<br />
57
+
[Sample: Use QueryExpression with a paging cookie](/dynamics365/customer-engagement/developer/org-service/sample-use-queryexpression-with-a-paging-cookie)
[Sample: Convert queries between Fetch and QueryExpression](/dynamics365/customer-engagement/developer/org-service/sample-convert-queries-fetch-queryexpression)
0 commit comments