I am trying to write a QueryExpression in C# using the CRM SDK. Where I have a main query and some entities to join. My issue is that 1 of the entities that I join to has a field that I need to filter and cannot be null also.
var mainQuery = new QueryExpression([entity1])
{
ColumnSet = new ColumnSet("XXXX"),
};
var entity1Join = mainQuery.AddLink([fields], JoinOperator.Inner);
...[other joins here]
var entity2Join = entity1Join.AddLink("entity2", "fieldid", "fieldid", JoinOperator.Inner);
contactJoin.LinkCriteria = new FilterExpression()
{
FilterOperator = LogicalOperator.And,
Conditions = {
new ConditionExpression([field1], ConditionOperator.NotNull),
new ConditionExpression([field1], ConditionOperator.Equal, [value])
}
};
...[other joins here]
var result = this.CRMClient.OrganizationServiceProxy.RetrieveMultiple(mainQuery).Entities;
I get this error:
Condition for attribute 'entity2.field1': null is not a valid value for an attribute. Use 'Null' or 'NotNull' conditions instead.
Please help, thanks.