Filter collection with entities from another collection

Posts   
 
    
robertpnl
User
Posts: 6
Joined: 31-Jul-2007
# Posted on: 14-Nov-2007 21:41:11   

Hi simple_smile

The solution will be simple but what is the best way to filter an collection with entities from an another collection.

I have two collections: A and B. A is filled with entities and collection B is empty.

When I add an entity in collection B, I want that this entity will filtered from 'defaultview' of collection A (but not deleted from collection).

What is the best way to do this in memory (self-services). Must I use one of the predicate classes?

Thank you.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-Nov-2007 03:24:09   

Hi Robert,

You can create filtered-and-sorted views of your _EntityColllections _thanks to EntityViews. When you use entity views, the involved collection isn't changed. You can do that with normal _IPredicateExpressions _and _ISortExpressions _as you do with normal fetches.

Please read LLBLGenPro Help - Using generated code - SelfServicing - Using entityvies with entity collections.... and let us know if we can give you further assistance.

David Elizondo | LLBLGen Support Team
robertpnl
User
Posts: 6
Joined: 31-Jul-2007
# Posted on: 15-Nov-2007 12:24:00   

daelmo wrote:

Hi Robert,

You can create filtered-and-sorted views of your _EntityColllections _thanks to EntityViews. When you use entity views, the involved collection isn't changed. You can do that with normal _IPredicateExpressions _and _ISortExpressions _as you do with normal fetches.

Please read LLBLGenPro Help - Using generated code - SelfServicing - Using entityvies with entity collections.... and let us know if we can give you further assistance.

Hi daelmo,

Thank you for your reply. simple_smile

I understand the filtering system and EntityView can help me with this, but my problem is how to filter the values of an EntityView from values from an another collection (or another Entityview).

Maybe I can give you an example. The interface has two listboxes. One listbox (A) contains all values of an EntityView (from a collection). Listbox B (another listbox with a collection) is empty.

When user double click (for example) an item in listbox A, this item must be placed in listbox B (in the another collection). No problem with that, but this item must be removed from listbox A (thus filtered on the EntityView of collection).

What is the best way to filter this EntityView with different values from an another collection? Of course I can use 'foreach' or something like that, but maybe is there an another option in the generated code of Predicate class that helps me with this.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 15-Nov-2007 12:35:26   

There is no direct way. Try to filter in the PKs of the Entities added to the other collection.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 15-Nov-2007 13:05:27   

In v2.5 you can though. With a MemberPredicate. Please see the example in using the generated code -> adapter/selfservicing -> Filtering and sorting -> The predicate system -> Member predicate

Frans Bouma | Lead developer LLBLGen Pro