/// <summary> /// 删除数据 /// </summary> /// <param name="paraTb_Dealhistory"></param> /// <returns>true:删除成功,false:不存在该记录</returns> public bool deleteMode(tb_DealHistory paraTb_Dealhistory) { if(paraTb_Dealhistory == null) throw new ArgumentNullException("paraTb_Dealhistory"); try { var query = from p in _context.tb_DealHistory where p.DealHId == paraTb_Dealhistory.DealHId select p; if (query.ToList().Count<1) { return false; } else { foreach(var model in query.ToList()) { if(!_context.IsAttached(model)) _context.tb_DealHistory.Attach(model); _context.tb_DealHistory.DeleteObject(model); _context.SaveChanges(); } return true; } } catch (Exception ex) { throw ex; } }
/// <summary> /// 插入数据 /// </summary> /// <param name="paraTb_Dealhistory"></param> /// <returns>true:插入成功,false:已存在该记录</returns> public bool addMode(tb_DealHistory paraTb_Dealhistory) { if(paraTb_Dealhistory == null) throw new ArgumentNullException("paraTb_Dealhistory"); try { var query = from p in _context.tb_DealHistory where p.DealHId == paraTb_Dealhistory.DealHId select p; if (query.ToList().Count() > 0) { return false; } else { _context.tb_DealHistory.AddObject(paraTb_Dealhistory); _context.SaveChanges(); return true; } } catch (Exception ex) { throw ex; } }
/// <summary> /// 用于向 tb_DealHistory EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddTotb_DealHistory(tb_DealHistory tb_DealHistory) { base.AddObject("tb_DealHistory", tb_DealHistory); }
/// <summary> /// 更新数据 /// </summary> /// <param name="paraTb_Dealhistory"></param> /// <returns>true:更新成功,false:更新数据失败,不存在该记录!</returns> public bool updateMode(tb_DealHistory paraTb_Dealhistory) { if(paraTb_Dealhistory == null) throw new ArgumentNullException("paraTb_Dealhistory"); try { var oldEntity = (from p in _context.tb_DealHistory where p.DealHId == paraTb_Dealhistory.DealHId select p).FirstOrDefault(); if (oldEntity == null) { return false; } else { _context.ApplyCurrentValues(oldEntity.GetType().Name, paraTb_Dealhistory); _context.SaveChanges(); return true; } } catch (Exception ex) { throw ex; } }
/// <summary> /// 创建新的 tb_DealHistory 对象。 /// </summary> /// <param name="dealHId">DealHId 属性的初始值。</param> public static tb_DealHistory Createtb_DealHistory(global::System.Int32 dealHId) { tb_DealHistory tb_DealHistory = new tb_DealHistory(); tb_DealHistory.DealHId = dealHId; return tb_DealHistory; }