/// <summary> /// 新增 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool AddModel(Base_Qry model) { bool returnFlag = false; using (DBContext dbContext = new DBContext()) { //增加 dbContext.Base_Qry.Add(model); dbContext.SaveChanges(); returnFlag = true; } return(returnFlag); }
/// <summary> /// 修改 /// </summary> /// <param name="model"></param> /// <param name="sid"></param> public static void UpdateModel(Base_Qry model, int sid) { using (DBContext dbContext = new DBContext()) { var editmodel = dbContext.Base_Qry.Where(u => u.id == sid).FirstOrDefault(); if (editmodel == null) { return;//空 } editmodel.keyVal = model.keyVal; editmodel.keyText = model.keyText; editmodel.viewOrder = model.viewOrder; editmodel.viewType = model.viewType; editmodel.Remark = model.Remark; //提交修改 dbContext.SaveChanges(); } }