示例#1
0
        /// <summary>
        /// Fast bulk insert to copy players of a grid to the log
        /// </summary>
        /// <param name="gridId"></param>
        public void BulkInsertPlayerLogs(int gridId)
        {
            var playerLogList = new List<PlayerLog>();
            var players = db.Players.Where(p => p.GridId == gridId).ToList();
            foreach (var p in players)
            {
                var playerLog = new PlayerLog(p);
                playerLogList.Add(playerLog);
            }

            var playerLogTable = playerLogList.ToDataTable();

            var connStr = ctx.Database.Connection.ConnectionString;
            using (var bcp = new SqlBulkCopy(connStr))
            {
                bcp.DestinationTableName = "PlayerLogs";
                bcp.WriteToServer(playerLogTable);
            }
        }
示例#2
0
 /// <summary>
 /// Add a player log entry to the database
 /// </summary>
 public void Add(PlayerLog playerLog, bool saveChanges)
 {
     db.PlayerLogs.Add(playerLog);
     if (saveChanges) db.SaveChanges();
 }
示例#3
0
 /// <summary>
 /// Remove a player log entry from database
 /// </summary>
 public void Remove(PlayerLog playerLog)
 {
     db.PlayerLogs.Remove(playerLog);
     db.SaveChanges();
 }
示例#4
0
 /// <summary>
 /// Add a player log entry to the database
 /// </summary>
 public void Add(PlayerLog playerLog)
 {
     Add(playerLog, true);
 }