Filtering and sorting on any property in an entity.

Posts   
 
    
C4 avatar
C4
User
Posts: 32
Joined: 12-Nov-2005
# Posted on: 06-May-2006 08:11:24   

Under the new verison, is it possible to filter based on the Count of a Collection (1:N releationship) ??? If so, can you give a code example of how to do this?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 06-May-2006 09:29:29   

You mean, from a collection of customers, select all customers which have 10 orders or more?

No, that's currently not possible directly. The filtering in-memory is done by interpreting a predicate expression based on an entity: the predicate expression either gives true or false. As the filtering system uses Predicate based classes, it's possible to write a predicateclass which does this kind of filtering for you, however it's not build in.

What you can do is add a property to Customer, which represents the Count of the OrdersCollection. You then can filter on that property.

Frans Bouma | Lead developer LLBLGen Pro
C4 avatar
C4
User
Posts: 32
Joined: 12-Nov-2005
# Posted on: 06-May-2006 20:16:07   

Otis wrote:

You mean, from a collection of customers, select all customers which have 10 orders or more?

No, that's currently not possible directly. The filtering in-memory is done by interpreting a predicate expression based on an entity: the predicate expression either gives true or false. As the filtering system uses Predicate based classes, it's possible to write a predicateclass which does this kind of filtering for you, however it's not build in.

What you can do is add a property to Customer, which represents the Count of the OrdersCollection. You then can filter on that property.

Gotcha, that's pretty easy.. then just override the save method and update the count to keep it in sync. Easy enough, thank-you!