Combine two entity collections

Posts   
 
    
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 04-May-2009 03:22:00   

Hi, i have an entity collection callsed users1, and another one called users2. in users1 collection i have user1, user2 and user3. in users2 collection u have user2, user4,user5.

is there a native way in llblgen to combine this two collections and get a new one that has the distinct entities of both collections? so the final collection will have user1 thru user5 and not have user2 twice.

i know i can loop through the entities of the second collection and if one doesnt exist in the first collection add it to the first collection. i am just asking for a native way to do this

thanks -shane

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 04-May-2009 04:44:31   

Hi Shane, you could do that some like this:

UserCollection mergedUsers = new UserCollection();
mergedUsers.DoNotPerformAddIfPresent = true;
mergedUsers.AddRange(users1);
mergedUsers.AddRange(users2);
David Elizondo | LLBLGen Support Team
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 04-May-2009 05:21:22   

thanks David -shane

daelmo wrote:

Hi Shane, you could do that some like this:

UserCollection mergedUsers = new UserCollection();
mergedUsers.DoNotPerformAddIfPresent = true;
mergedUsers.AddRange(users1);
mergedUsers.AddRange(users2);