ValeraT1982 / ObjectsComparer

C# Framework provides mechanism to compare complex objects, allows to override comparison rules for specific properties and types.
MIT License
352 stars 86 forks source link

Comparing collections not depending on the order of their elements #16

Closed ReinerVelte closed 4 years ago

ReinerVelte commented 4 years ago

First of all thanks for the your great tool !! I am trying to use in my current project. Working with entities, the load order of entities can vary, so I am searching for a way to compare collections disregarding the load order, so that basically (1, 2, 3) should be equal to (1, 3, 2). Do you have any suggestions how to achieve that?

(Maybe this is not even a issue, but I didn't see another way to contact you)

ValeraT1982 commented 4 years ago

@ReinerVelte thank you for asking. You can write custom comparer for you list like in Example 4: Custom comparer for list Please let me know if you have any questions.

ReinerVelte commented 4 years ago

Dear Valerii,

Many thanks for your kind reply.

I managed to write a custom comparer to do – almost – what I wanted to do. The only thing I didn’t manage to achive is to call an appropriate comparer to compare collection elements in depth and not by the regular .NET Equals method. I think I have to split my rather large comparer configured for an object hierarchy of about 20 types into different smaller comparers for smaller parts of the hierarchy, using a factory.

Anyway, for the moment we consider to rely on the built in comparison method relying on the same sequence of objects in the collections we compare.

If we need further customization, would it be OK for you to send you a small code sample? Is it OK for you to contact you through github or do you prefer a different channel for communication?

Best regards, Reiner

Von: Valerii Tereshchenko notifications@github.com Gesendet: Mittwoch, 22. Januar 2020 23:07 An: ValeraT1982/ObjectsComparer ObjectsComparer@noreply.github.com Cc: Reiner Velte rv@velte-software.de; Mention mention@noreply.github.com Betreff: Re: [ValeraT1982/ObjectsComparer] Comparing collections not depending on the order of their elements (#16)

@ReinerVeltehttps://github.com/ReinerVelte thank you for asking. You can write custom comparer for you list like in Example 4: Custom comparer for list Please let me know if you have any questions.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ValeraT1982/ObjectsComparer/issues/16?email_source=notifications&email_token=AEM3OHHRS25OLMSYHEM4E63Q7C7RBA5CNFSM4KKCS7EKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJVI5NI#issuecomment-577408693, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEM3OHFKMXVYFODHKQUY4OLQ7C7RBANCNFSM4KKCS7EA.

ValeraT1982 commented 4 years ago

@ReinerVelte , it's OK to send me a code samples to review. It would be interesting for me to know more about how this framework can be used. I sent you an invitation and email to your linkedin profile.