public override void End() { using (var cn = _cf.GetConnection()) { cn.Open(); var sql = Context.SqlControlEndBatch(_cf); if (_cf.AdoProvider == AdoProvider.Access) { var cmd = cn.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = sql; var inserts = cmd.CreateParameter(); inserts.ParameterName = "Inserts"; inserts.DbType = DbType.Int32; inserts.Value = Convert.ToInt32(Context.Entity.Inserts); var updates = cmd.CreateParameter(); updates.ParameterName = "Updates"; updates.DbType = DbType.Int32; updates.Value = Convert.ToInt32(Context.Entity.Updates); var deletes = cmd.CreateParameter(); deletes.ParameterName = "Deletes"; deletes.DbType = DbType.Int32; deletes.Value = Convert.ToInt32(Context.Entity.Deletes); var end = cmd.CreateParameter(); end.ParameterName = "End"; end.DbType = DbType.Date; end.Value = DateTime.Now; var entity = cmd.CreateParameter(); entity.ParameterName = "Entity"; entity.DbType = DbType.String; entity.Value = Context.Entity.Alias; var batchId = cmd.CreateParameter(); batchId.ParameterName = "BatchId"; batchId.DbType = DbType.Int32; batchId.Value = Context.Entity.BatchId; cmd.Parameters.Add(inserts); cmd.Parameters.Add(updates); cmd.Parameters.Add(deletes); cmd.Parameters.Add(end); cmd.Parameters.Add(entity); cmd.Parameters.Add(batchId); cmd.ExecuteNonQuery(); } else { try { cn.Execute(sql, new { Inserts = Convert.ToInt64(Context.Entity.Inserts), Updates = Convert.ToInt64(Context.Entity.Updates), Deletes = Convert.ToInt64(Context.Entity.Deletes), End = DateTime.Now, Entity = Context.Entity.Alias, Input = Context.Entity.Input, Context.Entity.BatchId }); } catch (System.Data.Common.DbException e) { Context.Error("Error writing to the control table."); Context.Error(e.Message); Context.Debug(() => e.StackTrace); Context.Debug(() => sql); return; } } if (cn.State != ConnectionState.Closed) { cn.Close(); } } OutputProvider.End(); _stopWatch.Stop(); Context.Debug(() => $"Entity {Context.Entity} ending {_stopWatch.Elapsed}"); }