I have a class with many properties, some of them are lists of custom types. I need to compare two instances of this class, and get a list of properties that aren't equal in them.
I designed it with custom attributes (for the relevant properties that I want to include in the comparison), and using the IEquatable
, but for the lists I ran into problems. I was going to use SequenceEqual
but it requires the type of the list (IEnumerable<SomeType>
), which I don't have and don't know how to set. I'm aware of the GetElementType
and GetGenericArguments
methods but I can't use them inside IEnumerable<>
to make the SequenceEqual
work.
I'm looking for the best design for this scenario, and also code examples of how to actually do it.