Best way: Projection or EntityCollection Constructor - WCF

Posts   
 
    
ianvink
User
Posts: 394
Joined: 15-Dec-2006
# Posted on: 07-Oct-2007 15:27:23   

Once a client has received an IEntityCollection2 from a WCF service, I'd like to copy all the Entities to a local EntityCollection<MyEntity>.

Which of these ways is the preferred way?

1) Using the Projections feature, project the source IEntityCollection2 to the local EntityCollection<MyEntity>

2) Passing in the IEntityCollection2 received from the WCF service into the constructor of the local EntityCollection like this:

EntityCollection<MyEntity> qqqqq= new EntityCollection<MyEntity>(colFromWCF);
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-Oct-2007 23:02:21   

The second option is the most suitable in this case. The entitycollection constructor you are referring adds the range of passed entities to the new collection. simple_smile

Projections in most cases is used to copy the entityCollection contents to a structurally different object.

David Elizondo | LLBLGen Support Team