public void AddType(string name, string description)
 {
     try
     {
         Variety addModel = new Variety()
         {
             Name =StringHelper.LimitLength(name,50),
             Description = StringHelper.LimitLength(description,500)
         };
         db.AddToVarieties(addModel);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 /// <summary>
 /// 用于向 Varieties EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToVarieties(Variety variety)
 {
     base.AddObject("Varieties", variety);
 }
 /// <summary>
 /// 创建新的 Variety 对象。
 /// </summary>
 /// <param name="typeId">TypeId 属性的初始值。</param>
 /// <param name="name">Name 属性的初始值。</param>
 /// <param name="description">Description 属性的初始值。</param>
 public static Variety CreateVariety(global::System.Int32 typeId, global::System.String name, global::System.String description)
 {
     Variety variety = new Variety();
     variety.TypeId = typeId;
     variety.Name = name;
     variety.Description = description;
     return variety;
 }