Best way to compare two Dictionary<T> for equality
Is this the best way to create a comparer for the equality of two dictionaries? This needs to be exact. Note that Entity.Columns is a dictionary of KeyValuePair(string, object) : public class EntityColumnCompare : IEqualityComparer<Entity> { public bool Equals(Entity a, Entity b) { var aCol = a.Columns.OrderBy(KeyValuePair => KeyValuePair.Key); var bCol = b.Columns.OrderBy(KeyValuePAir => KeyValuePAir.Key); if (aCol.SequenceEqual(bCol)) return true; else return false; } public int GetHashCode(Entity obj) { return obj.Columns.GetHashCode(); } } Also not too sure about the GetHashCode