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