Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueryCommand"/> class.
 /// </summary>
 /// <param name="sql">The SQL.</param>
 /// <param name="providerName">Name of the provider.</param>
 public QueryCommand(string sql, string providerName)
 {
     ProviderName = providerName;
     Provider     = DataService.GetInstance(providerName);
     CommandSql   = sql;
     CommandType  = CommandType.Text;
     parameters   = new QueryParameterCollection();
     OutputValues = new List <object>();
 }
Пример #2
0
 public QueryCommand(string sql)
 {
     //use the default
     ProviderName = DataService.Provider.Name;
     Provider     = DataService.Provider;
     CommandSql   = sql;
     CommandType  = CommandType.Text;
     parameters   = new QueryParameterCollection();
     OutputValues = new List <object>();
 }
Пример #3
0
        /// <summary>
        /// Adds the parameter. The public AddParameter methods should call this one.
        /// </summary>
        /// <param name="parameterName">Name of the parameter.</param>
        /// <param name="parameterValue">The parameter value.</param>
        /// <param name="maxSize">Size of the max.</param>
        /// <param name="dbType">Type of the db.</param>
        /// <param name="direction">The direction.</param>
        private void AddParameter(string parameterName, object parameterValue, int maxSize, DbType dbType, ParameterDirection direction, int?scale, int?precision)
        {
            if (parameters == null)
            {
                parameters = new QueryParameterCollection();
            }

            QueryParameter param = new QueryParameter();

            param.ParameterName  = Utility.PrefixParameter(parameterName, Provider);
            param.ParameterValue = parameterValue ?? DBNull.Value;
            param.Mode           = direction;
            param.DataType       = dbType;
            param.Scale          = scale;
            param.Precision      = precision;

            if (maxSize > -1 && direction != ParameterDirection.Output)
            {
                param.Size = maxSize;
            }

            parameters.Add(param);
        }
Пример #4
0
        /// <summary>
        /// Adds the parameter. The public AddParameter methods should call this one.
        /// </summary>
        /// <param name="parameterName">Name of the parameter.</param>
        /// <param name="parameterValue">The parameter value.</param>
        /// <param name="maxSize">Size of the max.</param>
        /// <param name="dbType">Type of the db.</param>
        /// <param name="direction">The direction.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="precision">The precision.</param>
        private void AddParameter(string parameterName, object parameterValue, int maxSize, DbType dbType, ParameterDirection direction, int?scale, int?precision)
        {
            if (parameters == null)
            {
                parameters = new QueryParameterCollection();
            }

            QueryParameter param = new QueryParameter
            {
                ParameterName  = CommandType == CommandType.StoredProcedure ? parameterName : Provider.FormatParameterNameForSQL(parameterName),
                ParameterValue = parameterValue ?? DBNull.Value,
                Mode           = direction,
                DataType       = dbType,
                Scale          = scale,
                Precision      = precision
            };

            if (maxSize > -1 && direction != ParameterDirection.Output)
            {
                param.Size = maxSize;
            }

            parameters.Add(param);
        }