在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
前台传来明细 ,判断是否修改,在把前台 的数据组成新的类保存 1 public class tt 2 { 3 public string id { get; set; } 4 public string e_id { get; set; } 5 public string name { get; set; } 6 public int age { get; set; } 7 public bool sex { get; set; } 8 9 } 10 public class t 11 { 12 public string id { get; set; } 13 public string name { get; set; } 14 public List<tt> dd { get; set; } 15 } 16 class Program 17 { 18 19 static void Main(string[] args) 20 { 21 var q = new List<tt> { new tt { id = "123",e_id="1", name = "pg", age = 12, sex = true }, new tt { id = "124",e_id="1", name = "pp", age = 13, sex = true } }; //后台数据 22 var w = new List<tt> { new tt { name = "pg", e_id = "2", age = 12, sex = true }, new ConsoleApplication2.tt { name = "pp", e_id = "2", age = 13, sex = true }, new tt { name = "ppd", e_id = "2", age = 11, sex = true } }; //前台数据 23 24 var e = new t { id = "1", name = "pg", dd = q }; //父行 25 26 var ischange1 = false; 27 var ischange2 = false; 28 foreach (var item in w) 29 { 30 item.e_id = e.id; //父ID 31 tt ex = q.Where(d => d.name == item.name).FirstOrDefault(); 32 if (ex == null) 33 { 34 ischange2 = true; 35 } 36 else 37 { 38 if (ex.age != item.age || ex.sex != item.sex) 39 { 40 ischange2 = true; 41 } 42 } 43 } 44 45 if (q.Count != w.Count) 46 { 47 ischange2 = true; 48 } 49 if (ischange1 == true || ischange2 == true) 50 { 51 if (ischange2 == true) 52 { 53 e.dd = w; 54 } 55 } 56 Console.WriteLine(ischange2); 57 58 Console.ReadKey(true); 59 } 60 61 }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论