コード例 #1
0
ファイル: MapNpcDAO.cs プロジェクト: Ziratoxdu36/OpenNos
 public MapNpcDTO Insert(MapNpcDTO npc)
 {
     try
     {
         using (var context = DataAccessHelper.CreateContext())
         {
             MapNpc entity = _mapper.Map <MapNpc>(npc);
             context.MapNpc.Add(entity);
             context.SaveChanges();
             return(_mapper.Map <MapNpcDTO>(entity));
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
         return(null);
     }
 }
コード例 #2
0
ファイル: MapNpcDAO.cs プロジェクト: Ziratoxdu36/OpenNos
 public void Insert(List <MapNpcDTO> npcs)
 {
     try
     {
         using (var context = DataAccessHelper.CreateContext())
         {
             context.Configuration.AutoDetectChangesEnabled = false;
             foreach (MapNpcDTO Item in npcs)
             {
                 MapNpc entity = _mapper.Map <MapNpc>(Item);
                 context.MapNpc.Add(entity);
             }
             context.Configuration.AutoDetectChangesEnabled = true;
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
 }