/// <summary> /// Compares the objects. /// </summary> /// <param name="obj1">The obj1.</param> /// <param name="obj2">The obj2.</param> /// <param name="source">The source.</param> /// <returns>True if they're the same, false otherwise.</returns> protected static bool CompareObjects(object obj1, object obj2, IMappingSource source) { if (ReferenceEquals(obj1, obj2)) { return(true); } var Object1Type = obj1.GetType(); if (Object1Type != obj2.GetType()) { return(false); } var ObjectIDs = source.GetParentMapping(Object1Type).SelectMany(x => x.IDProperties); if (!ObjectIDs.Any()) { return(false); } foreach (var ObjectID in ObjectIDs) { var Value1 = ObjectID.GetColumnInfo()[0].GetValue(obj1); var Value2 = ObjectID.GetColumnInfo()[0].GetValue(obj2); if (!Equals(Value1, Value2) || ObjectID.GetColumnInfo()[0].IsDefault(obj1)) { return(false); } } return(true); }