예제 #1
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);
        }
예제 #2
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);
        }