Comparing 2 collections?

Posts   
 
    
netLearner
User
Posts: 150
Joined: 18-Oct-2003
# Posted on: 18-Mar-2005 15:08:50   

Hi Frans Is there a good approach to compare 2 collections and get their differences? Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 18-Mar-2005 18:01:49   

What is it exactly that you want to compare? The entities and all their fields or do you just want to check if the collections contain the same entities?

Frans Bouma | Lead developer LLBLGen Pro
netLearner
User
Posts: 150
Joined: 18-Oct-2003
# Posted on: 18-Mar-2005 19:25:23   

Yes, the entities and all their fields. Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 19-Mar-2005 11:16:58   

netLearner wrote:

Yes, the entities and all their fields. Thanks.

If you have to compare all the fields as well, it requires 2 nested loops. If you just want to check if an entity is also in the other collection (PK check) you can use 1 loop and use entity.Equals(otherEntity)

Frans Bouma | Lead developer LLBLGen Pro