Implementing complex filters

Posts   
 
    
laurendc
User
Posts: 4
Joined: 05-Oct-2009
# Posted on: 27-Nov-2009 22:31:18   

Hi,

I am new to LLBLGen, and would like to implement a complex filter. I use the adapter model.

Trying to fetch an entityCollection using the following query :

 select top 1 id
 from   MyTable
 where major_id= @majorId and @asOf >= from_date
 order by from_date asc

How can I do this?

Thanks C

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Nov-2009 05:10:49   

This is an approximate code. For more info please read Filtering and Sorting.

IRelationPredicateBucket filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(YourTableFields.MajorId = majorId);
filter.PredicateExpression.Add(YourTableFields.FromDate < asOf);

ISortExpression sorter = new SortExpression();
sorter.Add(YourTableFields.FromDate | SortOperator.Ascending);

EntityCollection<YourTableEntity> coll = new EntityCollection<YourTableEntity>();
using (DataAccessAdapter = new DataAccessAdapter())
{
     adapter.FetchEntityCollection(coll, filter, 0, sorter);
}
David Elizondo | LLBLGen Support Team