Filter with "Not In"

Posts   
 
    
Posts: 7
Joined: 08-Sep-2005
# Posted on: 24-Sep-2006 19:43:47   

My apologies if this has already been answered. I did search but couldn't find it. I am using Self Servicing code generated by version 2.0 with .NET 2.0.

My problem: I have a Survey table and a SurveyNomination table. Survey and SurveyNomination are related 1:n, SurveyNomination also contains a UserID column that is of interest here.

I would like to retrieve a Surveycollection, but filter out those Surveyentitities whose SurveyID exists in the SurveyNomination table (ie. a related row is present) for a specific UserID in the SurveyNomination table (ie. if the UserID in the related row matches a given value).

I hope I have made the problem clear enough.

Any help would be much appreciated. Thanks Sumeet

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 25-Sep-2006 08:12:07   

You should use a FieldCompareSetPredicate, with negation (negate=true). Please refer to the LLBLGen Pro manual: "Using the generated code -> SelfServicing -> Filtering and sorting -> The predicate system"

filter.Add(new FieldCompareSetPredicate(
    SurveyFields.ID, SurveyNominationFields.SurveyID,
    SetOperator.In, (SurveyNominationFields.UserID == xx), true));
Posts: 7
Joined: 08-Sep-2005
# Posted on: 25-Sep-2006 21:41:12   

Thanks Walaa, I knew I was missing something obvious. Sumeet