I'm using Microsoft CRM SDK to retrieve entities. I'm writing QueryExpression
with FilterExpression
.
How to write a condition, that takes two attributes in consideration? I want to retrieve entities, for which attribute "Export Date" is less than "Modified On". (ie. all that have been modified since last export).
QueryExpression query = new QueryExpression();
FilterExpression filter = new FilterExpression();
filter.FilterOperator = LogicalOperator.Or;
ConditionExpression condition = new ConditionExpression();
// ...
//how to write this condition?
filter.AddCondition(condition);
When querying CRM, the following restrictions apply:
In other words, attributes can't be compared directly in a single query.
As a rule of thumb, if your QueryExpression
can be built as Advanced Find then you're okay, otherwise you're most likely going to need intermediate queries.
In latest version (July 2020), the feature to compare the two attributes of same entity is available in Query Expression (SDK), fetchxml and web api. Read more
This code creates a condition to return only records where the first and last names are the same
new ConditionExpression("firstname", ConditionOperator.Equal, true, "lastname");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With