linq - Comparing two collections -


I think a common problem / pattern looks like two collection objects of the same object have many properties and in it There are some nested objects. The car has a property called the ID, which is a unique identifier.

I want to find LINQ to do a diff, which includes:

  1. Items in a collection and not other (unlike the visa)
  2. Are there any changes to the item, (changes will be compared to all the properties? (I just care about the settings properties, will I use the reflection for it?)

You can use the Enumerable.Except () method. Either a default or you supplied), to evaluate whether the objects are in both views or only one:

  var sequence A = new [] {"a "Sequence" sequence def = sequence Axide B);  

If you want a complete separation of both the sequence (ab) union (ba) , then you have to use it:

< Pre> var sequence def = sequence A.Except ( Nukrm B) ion (sequence BkExcept sequence (A));

If you have a complex type, you can use a IComparer & lt; T & gt; and use comparative accepting overloads.

For the second part of your question, you have to roll your own implementation to report how different types of properties are different .. There is nothing directly built in the Net BCL . You have to decide how will this report take? How would you recognize the difference in a complex type and express it? You can definitely use reflection for it ... but if you are working in only one type then I will avoid it, and I will write a specific shape utility for it. If you are going to support any type of beer category, then reflection can be more understood.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -