I came up with this, but it's throwing an error...
MemberCollection members = new MemberCollection();
IPredicate pred = (new FieldCompareSetPredicate(MemberFields.MemberId,
BodyCompFields.MemberId, SetOperator.In,
((BodyCompFields.ContestId == contestID) &
(BodyCompTypeFields.BodyCompTypeId == 1) &
(new FieldCompareSetPredicate(MemberFields.MemberId,
BodyCompFields.MemberId,
SetOperator.Exist, ((BodyCompFields.ContestId == contestID) &
(BodyCompTypeFields.BodyCompTypeId == 2)))))));
members.getMulti(pred);
The VisualStudio Predicate Visualizer says the predicate is the following:
MemberEntity.[MemberId] IN
(
SELECT BodyCompEntity.[MemberId] FROM BodyCompEntity WHERE
(
(
BodyCompEntity.[ContestId] = @ContestId1 AND BodyCompTypeEntity.[BodyCompTypeId] = @BodyCompTypeId2
)
AND EXISTS
(
SELECT BodyCompEntity.[MemberId] FROM BodyCompEntity WHERE
(
BodyCompEntity.[ContestId] = @ContestId3 AND BodyCompTypeEntity.[BodyCompTypeId] = @BodyCompTypeId4
)
)
)
Which is EXACTLY what I want...but when it's run, it gives me the following error:
{"An exception was caught during the execution of a retrieval query: The multi-part identifier \"ContestMS.dbo.BodyCompType.BodyCompTypeID\" could not be bound.\r\nThe multi-part identifier \"ContestMS.dbo.BodyCompType.BodyCompTypeID\" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception."}
It's like it's trying to assign the inner EXISTS select subquery to another value... I just want a plain exists. Well, I don't know what's wrong with it...but I've tried a lot of combinations and can't seem to come up with something that works.
I've tried (referring to the second FieldCompareSetPredicate in the statement above)
....(new FieldCompareSetPredicate(BodyCompFields.BodyCompID, BodyCompFields.BodyCompID, ...
....(new FieldCompareSetPredicate(null,null, ...
....(new FieldCompareSetPredicate(BodyCompFields.MemberID, null, ...
Truth is I don't care what the select statement brings back... I just want to know if the second record exists.
Help?
Thanks,
-Renée