コード例 #1
0
 public static void insertLevel(MemberTable <Ship> ships)
 {
     using (LevelLogDBContext context = new LevelLogDBContext())
     {
         Models.LevelLog levelLog;
         foreach (Ship ship in ships.Values)
         {
             if (ship.IsLocked)
             {
                 levelLog = context.LevelLogs.Find(ship.Id, DateTime.Now.Date);
                 //.SqlQuery<Models.LevelLog>("SELECT * FROM LevelLog WHERE Id = {0} AND InsertDate = {1}",
                 //ship.Id, DateTime.Now.ToString("yyyy/MM/dd")).FirstAsync().Result;
                 if (null == levelLog)
                 {
                     levelLog            = new Models.LevelLog();
                     levelLog.Id         = ship.Id;
                     levelLog.ShipId     = ship.Info.Id;
                     levelLog.InsertDate = DateTime.Now.Date;
                     levelLog.Level      = ship.Level;
                     context.LevelLogs.Add(levelLog);
                 }
                 else
                 {
                     levelLog.Level  = ship.Level;
                     levelLog.ShipId = ship.Info.Id;
                 }
             }
         }
         context.SaveChanges();
     }
 }
コード例 #2
0
 private static void createLevelTable()
 {
     using (LevelLogDBContext context = new LevelLogDBContext())
     {
         context.LevelLogs.Create();
         context.SaveChanges();
     }
 }