Relations - Multiple of same type

Posts   
 
    
Posts: 34
Joined: 08-Nov-2007
# Posted on: 08-Nov-2007 12:40:23   

Say I have Customer, and Pet, and CustomerPet, entities.

On the CustomerPet entity I have CustomerPetId, CustomerId, PetId, Adopted, DiedOrReturned

I want on Customer to have two Collections,

CurrentPets (basically DiedOrReturned == null)

and

AllPetsAdopted (all)

I know I can add IRelationPredicateBucket so that Customer.Pets is filtered, however I'd lose my other collection and I'd have to go back to the dataadpter to get it to show all pets if that was toggled, I rather have the two collections in the entity. So I thought I'd just add a collection in custom code and either pull this from DB via predicates or filter over the Pets entity, this solves the read-only situation I guess, however I want this CurrentPets to be editable (binding via wpf), so any changes to Pets in CurrentPets can be persisted back to the database when calling a recursive save. Any easy way?

If the designer let me add multiple relations of the same type I could have different IRelationPredicateBucket on each and I guess the update logic would work.. however the designer doesnt let me do this..

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 08-Nov-2007 14:08:23   

I recommend using an EntityView on the AllPetsAdopted (with the appropriate filter). And if you want, you may define this entityView as a Property in your entityClass.

You may also define an EntityCollection (instead of an EntityView) which is filled from the EntityView, using entityView.ToEntityCollection().