常用方法
常用方法
常用方法
常用方法
public static void Save(UsersViewModel model) { using (var db = new ShlekenEntities3()) { if (model.Id > 0) { var item = db.Users.Single(i => i.Id == model.Id); item = model.Map <UsersViewModel, Users>(item); db.SaveChanges(); } else { var item = model.Map <UsersViewModel, Users>(); item.AccountId = Userservice.AccountId; db.Users.Add(item); db.SaveChanges(); } } }