Пример #1
0
 public void AddMedal(int type,int rank, string name, string description, string imagePath)
 {
     try
     {
         Medal addModel = new Medal()
         {
             Type=type,
             Rank=rank,
             Name = StringHelper.LimitLength(name),
             Description = StringHelper.LimitLength(description,500),
             ImagePath =StringHelper.LimitLength(imagePath,200)
         };
         db.AddToMedals(addModel);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 /// <summary>
 /// 用于向 Medals EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToMedals(Medal medal)
 {
     base.AddObject("Medals", medal);
 }
 /// <summary>
 /// 创建新的 Medal 对象。
 /// </summary>
 /// <param name="medalId">MedalId 属性的初始值。</param>
 /// <param name="name">Name 属性的初始值。</param>
 /// <param name="description">Description 属性的初始值。</param>
 /// <param name="imagePath">ImagePath 属性的初始值。</param>
 /// <param name="rank">Rank 属性的初始值。</param>
 /// <param name="type">Type 属性的初始值。</param>
 public static Medal CreateMedal(global::System.Int32 medalId, global::System.String name, global::System.String description, global::System.String imagePath, global::System.Int32 rank, global::System.Int32 type)
 {
     Medal medal = new Medal();
     medal.MedalId = medalId;
     medal.Name = name;
     medal.Description = description;
     medal.ImagePath = imagePath;
     medal.Rank = rank;
     medal.Type = type;
     return medal;
 }