So far, reflection seems to be the only way to dynamically check if two objects are the same. You would do this by iterating through the object’s members and checking for which ones contain a different value. However, research has told me that reflection is bad on performance when used this way.
If someone can confirm here whether or not reflection is indeed not a good choice for what I need to do, perhaps there is an alternative?
Note that, whatever route I go, I need the solution to be dynamic. This means no overriding of Equals and then comparing each property one by one. If it’s dynamic, I can write one method that will work for all types.
Reflection is a good way to do it. So is writing your own object hashing method. If you write a hashing method that looks at all properties that need to be compared and makes a hash out of it, it should be a pretty fast comparision. You’ll probably need to use reflection for that as well. Sort of an override of object.GetHashCode() but do not take into account which reference is being looked at – just values.
Try something – then decide whether performance is a problem afterwards.