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(); } }
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); } }