Populating EntityCollection field without a fetch

Posts   
 
    
Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 08-Apr-2005 18:36:30   

If I create a new instance of the orders entity, it will have an OrderDetailsCollection field, which when filled, is a collection of OrderDetail entities.

If some other code has fetched an OrderDetailsCollection into variable tmpOrderDetails can I set the NewOrder.OrderDetailsCollection = tmpOrderDetails.

Entity.EntityCollection is read only, so I know I cannot set it in this fashion. What would be the best approach to setting the value of Entity.EntityCollection?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 09-Apr-2005 11:36:13   

you can't set that because the collection has to know in which entity it is contained for synchronization purposes.

A loop with Add() is the right way to go. Do not use AddRange(), because that one will use CollectionBase's Add().

I'll make sure these routines are properly overridden in 1.0.2004.2

Frans Bouma | Lead developer LLBLGen Pro