Пример #1
0
        internal static SqlCommand CreateCommand(
            SqlConnection connection,
            string sqlCommand,
            CommandType commandType,
            IEnumerable <IDataParameter> parameters,
            DbSetting databaseSetting)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }
            if (sqlCommand == null)
            {
                throw new ArgumentNullException(nameof(sqlCommand));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }
            if (databaseSetting == null)
            {
                throw new ArgumentNullException(nameof(databaseSetting));
            }

            var command = new SqlCommand(sqlCommand, connection)
            {
                CommandType    = commandType,
                CommandTimeout = databaseSetting.Timeout
            };

            foreach (var parameter in parameters)
            {
                command.Parameters.Add(parameter);
            }

            return(command);
        }
Пример #2
0
 public virtual IDataReader ExecuteSelect(string storedProcedureName, IEnumerable <IDataParameter> parameters, DbSetting databaseSetting)
 {
     return(ExecuteHelper.ExecuteSelect(storedProcedureName, CommandType.StoredProcedure, parameters, databaseSetting));
 }