Skip to content

Commit 5a2b5cd

Browse files
committed
Moved CE content to CDS
1 parent 4c52076 commit 5a2b5cd

File tree

2 files changed

+100
-3
lines changed

2 files changed

+100
-3
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: "Test for a null value (Common Data Service) | Microsoft Docs" # Intent and product brand in a unique string of 43-59 chars including spaces
3+
description: "This sample shows how to test for a null value by using the FilterExpression and QueryByAttribute classes"
4+
ms.custom: ""
5+
ms.date: 05/03/2019
6+
ms.reviewer: ""
7+
ms.service: powerapps
8+
ms.topic: "article"
9+
author: "KumarVivek" # GitHub ID
10+
ms.author: "kvivek" # MSFT alias of Microsoft employees only
11+
manager: "amyla" # MSFT alias of manager or PM counterpart
12+
search.audienceType:
13+
- developer
14+
search.app:
15+
- PowerApps
16+
- D365CE
17+
---
18+
19+
# Test for a null value
20+
21+
The following code example shows how to test for a null value by using the <xref:Microsoft.Xrm.Sdk.Query.FilterExpression> and <xref:Microsoft.Xrm.Sdk.Query.QueryByAttribute> classes.
22+
23+
## Example
24+
Use this code to test for equality by using the <xref:Microsoft.Xrm.Sdk.Query.FilterExpression> class.
25+
26+
```csharp
27+
FilterExpression null_filter = new FilterExpression(LogicalOperator.And);
28+
null_filter.FilterOperator = LogicalOperator.And;
29+
null_filter.AddCondition("leadid", ConditionOperator.Null);
30+
31+
```
32+
33+
## Example
34+
Use this code to test for inequality by using the <xref:Microsoft.Xrm.Sdk.Query.FilterExpression> class.
35+
36+
```csharp
37+
38+
FilterExpression filter = new FilterExpression(LogicalOperator.And);
39+
filter.FilterOperator = LogicalOperator.And;
40+
filter.AddCondition("leadid", ConditionOperator.NotNull);
41+
```
42+
43+
## Example
44+
Use this code to test for equality by using the <xref:Microsoft.Xrm.Sdk.Query.QueryByAttribute> class.
45+
46+
```csharp
47+
48+
QueryByAttribute qba = new QueryByAttribute("account");
49+
qba.ColumnSet = new ColumnSet("name","address1_stateorprovince");
50+
qba.AddAttributeValue("donotfax", null);
51+
```
52+
53+
### See also
54+
[Build Queries with QueryExpression](build-queries-with-queryexpression.md)
55+
[Page large result sets with FetchXML](page-large-result-sets-with-fetchxml.md)

powerapps-docs/developer/common-data-service/org-service/use-querybyattribute-class.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: "Use the QueryByAttribute class (Common Data Service) | Microsoft Docs" # Intent and product brand in a unique string of 43-59 chars including spaces
3-
description: "<Description>" # 115-145 characters including spaces. This abstract displays in the search result.
3+
description: "You can use the QueryByAttribute class to build queries that test a set of attributes against a set of values"
44
ms.custom: ""
5-
ms.date: 10/31/2018
5+
ms.date: 05/03/2019
66
ms.reviewer: ""
77
ms.service: powerapps
88
ms.topic: "article"
@@ -15,6 +15,48 @@ search.app:
1515
- PowerApps
1616
- D365CE
1717
---
18+
1819
# Use the QueryByAttribute class
1920

20-
<!-- https://docs.microsoft.com/dynamics365/customer-engagement/developer/org-service/use-querybyattribute-class -->
21+
You can use the <xref:Microsoft.Xrm.Sdk.Query.QueryByAttribute> class to build queries that test a set of attributes against a set of values. Use this class with the <xref:Microsoft.Xrm.Sdk.IOrganizationService.RetrieveMultiple*> method or the <xref:Microsoft.Xrm.Sdk.IOrganizationService>.<xref:Microsoft.Xrm.Sdk.Messages.RetrieveMultipleRequest> method.
22+
23+
The following table lists the properties that you can set to create a query expression using the <xref:Microsoft.Xrm.Sdk.Query.QueryByAttribute> class.
24+
25+
|Property|Description|
26+
|--------------|-----------------|
27+
|<xref:Microsoft.Xrm.Sdk.Query.QueryByAttribute.EntityName>|Specifies which type of entity is retrieved. A query expression can only retrieve a collection of one entity type. You can also pass this value by using the <xref:Microsoft.Xrm.Sdk.Query.QueryExpression> constructor.|
28+
|<xref:Microsoft.Xrm.Sdk.Query.QueryByAttribute.ColumnSet>|Specifies the set of attributes (columns) to retrieve.|
29+
|<xref:Microsoft.Xrm.Sdk.Query.QueryByAttribute.Attributes>|Specifies the set of attributes selected in the query.|
30+
|<xref:Microsoft.Xrm.Sdk.Query.QueryByAttribute.Values>|Specifies the attribute values to look for when the query is executed.|
31+
|<xref:Microsoft.Xrm.Sdk.Query.QueryByAttribute.Orders>|Specifies the order in which the records are returned from the query.|
32+
|<xref:Microsoft.Xrm.Sdk.Query.QueryByAttribute.PageInfo>|Specifies the number of pages and the number of records per page returned from the query.|
33+
34+
The following code example shows how to use the `QueryByAttribute` class.
35+
36+
```csharp
37+
// Create query using querybyattribute
38+
QueryByAttribute querybyexpression = new QueryByAttribute("account");
39+
querybyexpression.ColumnSet = new ColumnSet("name", "address1_city", "emailaddress1");
40+
41+
// Attribute to query
42+
querybyexpression.Attributes.AddRange("address1_city");
43+
44+
// Value of queried attribute to return
45+
querybyexpression.Values.AddRange("Detroit");
46+
47+
// Query passed to the service proxy
48+
EntityCollection retrieved = _serviceProxy.RetrieveMultiple(querybyexpression);
49+
50+
// Iterate through returned collection
51+
foreach (var c in retrieved.Entities)
52+
{
53+
System.Console.WriteLine("Name: " + c.Attributes["name"]);
54+
System.Console.WriteLine("Address: " + c.Attributes["address1_city"]);
55+
System.Console.WriteLine("E-mail: " + c.Attributes["emailaddress1"]);
56+
}
57+
58+
```
59+
60+
### See also
61+
[Build Queries with QueryExpression](build-queries-with-queryexpression.md)
62+
<xref:Microsoft.Xrm.Sdk.Query.QueryByAttribute>

0 commit comments

Comments
 (0)