public static string GetObjectUpdateInfo<T>(T old, T current) { string info = string.Empty;
Type type = typeof(T);
PropertyInfo[] propertys = type.GetProperties();
foreach (PropertyInfo property in propertys) { if (property.PropertyType.IsValueType || property.PropertyType.Name == "String") { if (property.PropertyType.FullName.Contains("Guid")) continue;
object o1 = property.GetValue(old, null); object o2 = property.GetValue(current, null); string str1 = o1 == null ? string.Empty : o1.ToString(); string str2 = o2 == null ? string.Empty : o2.ToString();
if (str1 != str2) info += property.Name + " from " + str1 + " to " + str2 + "\r\n "; } }
return info; }
转载于:https://www.cnblogs.com/fengguangqin/archive/2010/05/12/1733899.html
