public int Remove(int id) { T u1 = context.Set<T>().Find(id); //context.Set<T>().Remove(u1); //return context.SaveChanges(); context.Entry(u1).Property("IsDelete").IsModified = true; context.Entry(u1).Property("IsDelete").CurrentValue = true; return 0; } public int Remove(int[] ids) { int counter = ids.Length; for (int i = 0; i < counter; i++) { //T u1 = context.Set<T>().Find(ids[i]); //context.Set<T>().Remove(u1); Remove(ids[i]); } //return context.SaveChanges(); return 0; }
1 Person p = new Person(); 2 p.Id = 1; 3 p.Name = "张三"; 4 p.Sex = "男"; 5 p.Weight = 65; 6 p.Height = 180; 7 p.Birthday = DateTime.Now; 8 9 List<Person> pList = new List<Person>(); 10 pList.Add(p); 11 12 List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>(); 13 foreach (var Entity in pList) 14 { 15 Dictionary<string, object> row = new Dictionary<string, object>(); 16 foreach (PropertyInfo item in Entity.GetType().GetProperties()) 17 { 18 row.Add(item.Name, item.GetValue(Entity, null)); 19 } 20 rows.Add(row); 21 } 22 23 var RealRows = rows.ToList();