Export (0) Print
Expand All

Using the ConditionExpression Class

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

The ConditionExpression class is used to compare an attribute to a value or set of values by using an operator such as equal, greater than, or like.

The following table lists the properties that you set to create a condition by using the ConditionExpression class.

PropertyDescription
AttributeNameSpecifies the logical name of the attribute in the condition expression.
OperatorSpecifies the condition operator. This is set by using the ConditionOperator enumeration.
ValuesSpecifies the values of the attribute.

When you create a condition that compares an attribute value to an enumeration such as a state code, you must use the ToString method to convert the value to a string.

Example

The following code example shows how to use the ConditionExpression class.

// Create the ConditionExpression.
ConditionExpression condition = new ConditionExpression();

// Set the condition to be when the account owner's last name is not Cannon.
condition.AttributeName = "lastname";
condition.Operator = ConditionOperator.Equal;
condition.Values = new string [] {"Cannon"};

The following code example shows how to use the ConditionExpression class to test for the inactive state.

ConditionExpression ce = new ConditionExpression();
ce.AttributeName = "statecode";
ce.Operator = ConditionOperator.Equal;
ce.Values = new object[]{AccountState.Inactive.ToString()};

See Also

Other Resources


© 2010 Microsoft Corporation. All rights reserved.


Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft