예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <param name="direction"></param>
        public void AddParameter(string name, SqlDbType type, ParameterDirection direction = ParameterDirection.Output)
        {
            var _parameter = _command.CreateParameter();

            _parameter.ParameterName = AdoDotNetDbParameterHelpers.StringToParameterName(name);
            _parameter.SqlDbType     = type;
            _parameter.Direction     = direction;

            AddParameter(_parameter);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parameter"></param>
        public void AddParameters(object parameter)
        {
            var _parameters = _typeConverter.Convert <IReadOnlyNameValueCollection <string, object> >(parameter);

            foreach (var _parameter in _parameters)
            {
                var _name  = AdoDotNetDbParameterHelpers.StringToParameterName(_parameter.Key);
                var _value = _parameter.Value;

                _command.Parameters.AddWithValue(_name, _value);
            }
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <param name="type"></param>
        /// <param name="size"></param>
        /// <param name="direction"></param>
        public void AddParameter(string name, object value, SqlDbType type, int size, ParameterDirection direction = ParameterDirection.Input)
        {
            var _parameter = _command.CreateParameter();

            _parameter.ParameterName = AdoDotNetDbParameterHelpers.StringToParameterName(name);
            _parameter.Value         = value;
            _parameter.Size          = size;
            _parameter.SqlDbType     = type;
            _parameter.Direction     = direction;

            AddParameter(_parameter);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="size"></param>
        /// <param name="precision"></param>
        /// <param name="scale"></param>
        /// <param name="type"></param>
        /// <param name="direction"></param>
        public void AddParameter(string name, SqlDbType type, int size, byte precision, byte scale, ParameterDirection direction = ParameterDirection.Output)
        {
            var _parameter = _command.CreateParameter();

            _parameter.ParameterName = AdoDotNetDbParameterHelpers.StringToParameterName(name);
            _parameter.Size          = size;
            _parameter.Precision     = precision;
            _parameter.Scale         = scale;
            _parameter.SqlDbType     = type;
            _parameter.Direction     = direction;

            AddParameter(_parameter);
        }
예제 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="propertyDescriptor"></param>
        /// <param name="parameterName"></param>
        /// <param name="propertyDirection"></param>
        /// <returns></returns>
        protected virtual SqlParameter CreateParameter(DbQueryPropertyDescriptor propertyDescriptor, string parameterName, DbQueryPropertyDirections propertyDirection)
        {
            var _parameter = new SqlParameter();

            _parameter.ParameterName = AdoDotNetDbParameterHelpers.StringToParameterName(parameterName);
            _parameter.Direction     = AdoDotNetDbParameterHelpers.PropertyDirectionToParameterDirection(propertyDirection);
            _parameter.SqlDbType     = propertyDescriptor.DbType;
            _parameter.Size          = propertyDescriptor.Size;

            if (propertyDescriptor.DbType.Equals(SqlDbType.Decimal))
            {
                if (!ObjectUtils.IsNullOrDefault(propertyDescriptor.Scale))
                {
                    _parameter.Scale = propertyDescriptor.Scale;
                }

                if (!ObjectUtils.IsNullOrDefault(propertyDescriptor.Precision))
                {
                    _parameter.Precision = propertyDescriptor.Precision;
                }
            }

            return(_parameter);
        }
예제 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public bool ContainsParameter(string name)
 {
     return(-1 < _command.Parameters.IndexOf(AdoDotNetDbParameterHelpers.StringToParameterName(name)));
 }
예제 #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public void RemoveParameter(string name)
 {
     _command.Parameters.RemoveAt(AdoDotNetDbParameterHelpers.StringToParameterName(name));
 }
예제 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public SqlParameter GetParameter(string name)
 {
     return(_command.Parameters[AdoDotNetDbParameterHelpers.StringToParameterName(name)]);
 }
예제 #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <param name="direction"></param>
 public void AddParameter(string name, object value)
 {
     _command.Parameters.AddWithValue(AdoDotNetDbParameterHelpers.StringToParameterName(name), value);
 }