Created
January 31, 2011 20:12
-
-
Save butaji/804714 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Dictionary<string, object[]> CompareObjects<T>(T obj1, T obj2) | |
{ | |
var result = new Dictionary<string, object[]>(); | |
typeof(T) | |
.GetProperties() | |
.Select(p => new { p.Name, Val1 = p.GetValue(obj1, new object[] { }), Val2 = p.GetValue(obj2, new object[] { }) }) | |
.Where(i => i.Val1 != i.Val2) | |
.ToList() | |
.ForEach(p => result.Add(p.Name, new[] { p.Val1, p.Val2 })); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment