Example #1
0
        public void Execute(SqlConnection c, SqlTransaction tran, int commandTimeoutSecs)
        {
            _log.DebugFormat("Executing Table Builder");

            var sql = GenerateCommand();

            if (!string.IsNullOrEmpty(sql))
            {
                using (SqlCommand cmd = c.CreateCommand())
                {
                    if (tran != null)
                    {
                        cmd.Transaction = tran;
                    }

                    // give caller chance to view and modify sql...
                    var args = new ExecuteEventArgs {
                        SqlStatements = sql
                    };

                    OnBeforeExecute(args);
                    cmd.CommandTimeout = commandTimeoutSecs;
                    cmd.CommandText    = args.SqlStatements;
                    cmd.ExecuteNonQuery();
                }
            }
            else
            {
                _log.Warn("Table Builder has no tables!");
            }
        }
Example #2
0
 private void OnBeforeExecute(ExecuteEventArgs e)
 {
     BeforeExecute?.Invoke(this, e);
 }