Test for a null value

 

Updated: November 29, 2016

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

The following code example shows how to test for a null value by using the FilterExpression and QueryByAttribute classes.

Use this code to test for equality by using the FilterExpression class.

FilterExpression null_filter = new FilterExpression(LogicalOperator.And); 
null_filter.FilterOperator = LogicalOperator.And; 
null_filter.AddCondition("leadid", ConditionOperator.Null);

Use this code to test for inequality by using the FilterExpression class.


FilterExpression filter = new FilterExpression(LogicalOperator.And); 
filter.FilterOperator = LogicalOperator.And; 
filter.AddCondition("leadid", ConditionOperator.NotNull);

Use this code to test for equality by using the QueryByAttribute class.


QueryByAttribute qba = new QueryByAttribute("account"); 
qba.ColumnSet = new ColumnSet("name","address1_stateorprovince"); 
qba.AddAttributeValue("donotfax", null);

Microsoft Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright

Show: