How to use IN operator

Posts   
 
    
Sweety
User
Posts: 12
Joined: 21-Aug-2007
# Posted on: 10-Jun-2008 06:37:02   

Can you please tell me how to write the below query in llbl

select StatusName,StatusDesc from Status where StatusId in (1,2,3)
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 10-Jun-2008 07:31:45   

(assuming Adapter and C# and LLBLGenPro v2.0 or higher):

// collection to fetch
EntityCollection<StatusEntity> statusColl = new EntityCollection<StatusEntity>(new StatusEntityFactory());


// the relevant part
int[] values = new int[] { 1, 2, 3 };
IRelationPredicateBucket filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(StatusFields.StatusId == values);

// fetching results
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
     adapter.FetchEntityCollection(customers, filter);
}

Ref: LLBLGenPro Help -> Using the generated code -> Filtering and sorting -> The predicate system -> The predicate classes -> FieldCompareRangePredicate

David Elizondo | LLBLGen Support Team