From the code below:
public EntityCollection<ClientEntity> GetAllAvailableParticipants(int EventId)
{
IEnumerable<EventParticipantEntity> participants = new EventBLL().GetParticipantsByEventId(EventId);
int[] participantArray = participants.Select(i => i.EventId).ToArray();
EntityCollection<ClientEntity> output = new EntityCollection<ClientEntity>();
IRelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.PredicateExpression.Add(new FieldCompareRangePredicate(ClientFields.ClientId, null, participantArray));
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.FetchEntityCollection(output, bucket, 0);
}
return output;
}
How do I make this a NOT IN expression
bucket.PredicateExpression.Add(new FieldCompareRangePredicate(ClientFields.ClientId, null, participantArray));
This is the SQL syntax that I'm trying to come up with:
SELECT ClientId
FROM dbo.Client
WHERE (ClientId NOT IN
(SELECT ClientId
FROM dbo.EventParticipant))
Thanks
John