Esempio n. 1
0
 public void Add(CommodConfig config) {
     using (RxjhEntities en = new RxjhEntities()) {
         config.ID = Guid.NewGuid();
         en.CommodConfig.Add(config);
         en.SaveChanges();
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 添加一个最低价格装备
 /// 如果存在同一天的就修改价格
 /// </summary>
 /// <param name="commod">要添加的装备</param>
 public void Add(Commod commod) {
     using (RxjhEntities en = new RxjhEntities()) {
         //先找到当天是否已经存在该装备
         var thisDateCommod = en.Commod.Where(i => i.Name == commod.Name).FirstOrDefault();
         //存在就更新
         if (thisDateCommod != null)
         {
             en.Commod.Remove(thisDateCommod);
             commod.ID = Guid.NewGuid();
             en.Commod.Add(commod);
             en.SaveChanges();
         }
         else {
             commod.ID = Guid.NewGuid();
             en.Commod.Add(commod);
             en.SaveChanges();
         }
     }
 }