public DbParameter CreateParameter(string name, DbType type)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            return(new SqlParameter(name, type.ToSqlDbType()));
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColumnDefinition" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="dbType">The columns type.</param>
 /// <param name="length">The length (if fixed length).</param>
 /// <param name="fill">if set to <see langword="true" /> expects the column to be full (only appropriate for fixed length columns).</param>
 /// <param name="isNullable">if set to <see langword="true" /> the column is nullable.</param>
 /// <param name="defaultValue">The default value (required if column is not nullable).</param>
 /// <exception cref="System.ArgumentOutOfRangeException"></exception>
 ///   <exception cref="System.ArgumentOutOfRangeException"></exception>
 /// <remarks></remarks>
 public ColumnDefinition(
     [NotNull] string name,
     DbType dbType,
     int length      = -1,
     bool fill       = false,
     bool isNullable = true,
     [CanBeNull] object defaultValue = null)
     : this(name, dbType.ToSqlDbType(), length, fill, isNullable, defaultValue)
 {
 }
        public DbParameter CreateParameter(string name, DbType type, ParameterDirection direction, int size)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            return(new SqlParameter(name, type.ToSqlDbType(), size)
            {
                Direction = direction
            });
        }
        public DbParameter CreateParameter(string name, object value, DbType type, ParameterDirection direction)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            return(new SqlParameter(name, value)
            {
                Direction = direction,
                SqlDbType = type.ToSqlDbType()
            });
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ColumnDefinition" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="dbType">The columns type.</param>
 /// <param name="length">The length (if fixed length).</param>
 /// <param name="fill">if set to <see langword="true" /> expects the column to be full (only appropriate for fixed length columns).</param>
 /// <param name="isNullable">if set to <see langword="true" /> the column is nullable.</param>
 /// <param name="defaultValue">The default value (required if column is not nullable).</param>
 /// <exception cref="System.ArgumentOutOfRangeException"></exception>
 ///   <exception cref="System.ArgumentOutOfRangeException"></exception>
 /// <remarks></remarks>
 public ColumnDefinition(
     [NotNull] string name,
     DbType dbType,
     int length = -1,
     bool fill = false,
     bool isNullable = true,
     [CanBeNull] object defaultValue = null)
     : this(name, dbType.ToSqlDbType(), length, fill, isNullable, defaultValue)
 {
 }
Example #6
0
 public static SqlDbType AsSqlDbType(this DbType @this) => @this.ToSqlDbType();