public int AddDeal(DealModel deal) { try { Deal newDeal = new Deal(); newDeal.BuyManID = deal.BuyManID; newDeal.CarID = deal.CarID; newDeal.Price = deal.Price; newDeal.SaleManID = deal.SaleManID; newDeal.Time = deal.Time; context.AddToDeal(newDeal); context.SaveChanges(); return 1; } catch (Exception) { return 0; } }
/// <summary> /// 用于向 Deal EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToDeal(Deal deal) { base.AddObject("Deal", deal); }
/// <summary> /// 创建新的 Deal 对象。 /// </summary> /// <param name="id">ID 属性的初始值。</param> /// <param name="saleManID">SaleManID 属性的初始值。</param> /// <param name="buyManID">BuyManID 属性的初始值。</param> /// <param name="carID">CarID 属性的初始值。</param> /// <param name="price">Price 属性的初始值。</param> /// <param name="time">Time 属性的初始值。</param> public static Deal CreateDeal(global::System.Int32 id, global::System.Int32 saleManID, global::System.Int32 buyManID, global::System.Int32 carID, global::System.Decimal price, global::System.DateTime time) { Deal deal = new Deal(); deal.ID = id; deal.SaleManID = saleManID; deal.BuyManID = buyManID; deal.CarID = carID; deal.Price = price; deal.Time = time; return deal; }