System.Data.Common.DbCommand.AddParameter(string, System.Data.DbType, object, System.Data.ParameterDirection)

Here are the examples of the csharp api class System.Data.Common.DbCommand.AddParameter(string, System.Data.DbType, object, System.Data.ParameterDirection) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

1. Example

View license
public static DbCommand AddParameter(this DbCommand Command, string ID, SqlDbType Type,
            object Value = null, ParameterDirection Direction = ParameterDirection.Input)
        {
            Contract.Requires<ArgumentNullException>(Command != null, "Command");
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(ID), "ID");
            return Command.AddParameter(ID, Type.To(DbType.Int32), Value, Direction);
        }

2. Example

View license
public static DbCommand AddParameter(this DbCommand Command, string ID, SqlDbType Type,
            object Value = null, ParameterDirection Direction = ParameterDirection.Input)
        {
            Contract.Requires<ArgumentNullException>(Command != null, "Command");
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(ID), "ID");
            return Command.AddParameter(ID, Type.To(DbType.Int32), Value, Direction);
        }

3. Example

View license
public static DbCommand AddParameter<DataType>(this DbCommand Command, string ID, DataType Value = default(DataType),
            ParameterDirection Direction = ParameterDirection.Input)
        {
            Contract.Requires<ArgumentNullException>(Command != null, "Command");
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(ID), "ID");
            return Command.AddParameter(ID,
                new GenericEqualityComparer<DataType>().Equals(Value, default(DataType)) ? typeof(DataType).To(DbType.Int32) : Value.GetType().To(DbType.Int32),
                Value, Direction);
        }

4. Example

View license
public static DbCommand AddParameter<DataType>(this DbCommand Command, string ID, DataType Value = default(DataType),
            ParameterDirection Direction = ParameterDirection.Input)
        {
            Contract.Requires<ArgumentNullException>(Command != null, "Command");
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(ID), "ID");
            return Command.AddParameter(ID,
                new GenericEqualityComparer<DataType>().Equals(Value, default(DataType)) ? typeof(DataType).To(DbType.Int32) : Value.GetType().To(DbType.Int32),
                Value, Direction);
        }