/// <summary> /// Fast bulk insert to copy cells of a grid to the log /// </summary> /// <param name="gridId">GridId</param> public void BulkInsertCellLogs(int gridId) { var cellLogList = new List<CellLog>(); var cells = db.Cells.Where(c => c.GridId == gridId).ToList(); foreach (var c in cells) { var cellLog = new CellLog(c); cellLogList.Add(cellLog); } var cellLogTable = cellLogList.ToDataTable(); var connStr = ctx.Database.Connection.ConnectionString; using (var bcp = new SqlBulkCopy(connStr)) { bcp.DestinationTableName = "CellLogs"; bcp.WriteToServer(cellLogTable); } }
/// <summary> /// Add a cell log entry to the database /// </summary> public void Add(CellLog cellLog, bool saveChanges) { db.CellLogs.Add(cellLog); if(saveChanges) db.SaveChanges(); }
/// <summary> /// Remove a cell log entry from database /// </summary> public void Remove(CellLog cellLog) { db.CellLogs.Remove(cellLog); db.SaveChanges(); }
/// <summary> /// Add a cell log entry to the database /// </summary> public void Add(CellLog cellLog) { Add(cellLog, true); }