Hi,
i'm trying to perform a query which does a condition with NOT EXIST.
I've red about it in the documentation and it says to use FieldCompareSetPredicate, because EXIST is pretty much the same as IN.
This is a part of the SQL statement that i'm trying to use in my project:
AND NOT EXISTS (SELECT TransactionActivity.TransactionId
FROM TransactionActivity LEFT JOIN WorkerQueue ON TransactionActivity.EntityId=WorkerQueue.QueueItemId
WHERE t.TransactionId = TransactionActivity.TransactionId
AND WorkerQueue.CounterpartId = someId)
This is the part i have in my project and what does NOT work:
...
IPredicateExpression filter = new PredicateExpression();
...
IEntityRelation newSubQueryRelationActivity = new EntityRelation(); newSubQueryRelationActivity.AddEntityFieldPair(EntityFieldFactory.Create(TransactionActivityFieldIndex.EntityId),
EntityFieldFactory.Create(WorkerQueueFieldIndex.QueueItemId));
IRelationCollection subQueryRelationActivity = new RelationCollection();
subQueryRelationActivity.Add(newSubQueryRelationActivity, JoinHint.Left);
IPredicateExpression subQueryFilterActivity = new PredicateExpression(); subQueryFilterActivity.Add(PredicateFactory.CompareValue(TransactionFieldIndex.TransactionId,
ComparisonOperator.Equal, TransactionActivityFieldIndex.TransactionId, "t")); subQueryFilterActivity.AddWithAnd(PredicateFactory.CompareValue(WorkerQueueFieldIndex.CounterpartId,
ComparisonOperator.Equal, recipientId));
filter.AddWithAnd(new FieldCompareSetPredicate(TransactionFields.TransactionId, null,
TransactionActivityFields.TransactionId, null, SetOperator.Exist, subQueryFilterActivity,
subQueryRelationActivity, true));
...
Is there someone who can help me to trnsform the sql code to c# code?
Regards,
Jeffrey