示例#1
0
        internal void AddLevel(Level level)
        {
            using (var Ctx = new MysqlEntities())
            {
                var player = new Player
                {
                    ID     = level.Avatar.UserId,
                    Avatar = JsonConvert.SerializeObject(level.Avatar, this.Settings),
                };

                Ctx.Player.Add(player);
                Ctx.SaveChanges();
            }
        }
示例#2
0
 internal async void Save(List <Level> Levels)
 {
     using (var Ctx = new MysqlEntities())
     {
         foreach (Level pl in Levels)
         {
             lock (pl)
             {
                 Player p = Ctx.Player.Find(pl.Avatar.UserId);
                 if (p != null)
                 {
                     p.Avatar = JsonConvert.SerializeObject(pl.Avatar, this.Settings);
                 }
             }
         }
         await Ctx.BulkSaveChangesAsync(false);
     }
 }