Ejemplo n.º 1
0
 public void AddTrash(int typeId,string name,string description,bool canCount,decimal price)
 {
    try
     {
         Trash addModel=new Trash()
         {
             Name= StringHelper.LimitLength(name,50),
             Description=StringHelper.LimitLength(description,500),
             CanCount=canCount,
             DefaultPrice=price
         };
         db.AddToTrashes(addModel);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 /// <summary>
 /// 用于向 Trashes EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToTrashes(Trash trash)
 {
     base.AddObject("Trashes", trash);
 }
 /// <summary>
 /// 创建新的 Trash 对象。
 /// </summary>
 /// <param name="trashId">TrashId 属性的初始值。</param>
 /// <param name="name">Name 属性的初始值。</param>
 /// <param name="typeId">TypeId 属性的初始值。</param>
 /// <param name="canCount">CanCount 属性的初始值。</param>
 /// <param name="description">Description 属性的初始值。</param>
 /// <param name="defaultPrice">DefaultPrice 属性的初始值。</param>
 public static Trash CreateTrash(global::System.Int32 trashId, global::System.String name, global::System.Int32 typeId, global::System.Boolean canCount, global::System.String description, global::System.Decimal defaultPrice)
 {
     Trash trash = new Trash();
     trash.TrashId = trashId;
     trash.Name = name;
     trash.TypeId = typeId;
     trash.CanCount = canCount;
     trash.Description = description;
     trash.DefaultPrice = defaultPrice;
     return trash;
 }