标签:equal ati 两个泛型 tty ret code log mode lis
1 public static List<T> GetModiflyList<T>(List<T> newList, List<T> oldList, string keyField) 2 { 3 List<T> list = new List<T>(); 4 foreach (T newModel in newList) 5 { 6 object nob = newModel.GetType().GetProperty(keyField).GetValue(newModel, null); 7 T oldmodel = oldList.Find((delegate (T old) { object ob = old.GetType().GetProperty(keyField).GetValue(old, null); if (object.Equals(ob, nob)) return true; else return false; })); 8 if (oldmodel == null) 9 { 10 list.Add(newModel); 11 } 12 else 13 { 14 PropertyInfo[] pi = oldmodel.GetType().GetProperties(); 15 foreach (PropertyInfo p in pi) 16 { 17 object o_new = p.GetValue(newModel, null); 18 object o_old = p.GetValue(oldmodel, null); 19 if (object.Equals(o_new, o_old)) 20 continue; 21 else 22 { 23 list.Add(newModel); 24 break; 25 } 26 } 27 } 28 } 29 30 return list; 31 }
标签:equal ati 两个泛型 tty ret code log mode lis
原文地址:http://www.cnblogs.com/DjangoBlogs/p/6386085.html