AddParameter() публичный статический Метод

Add a parameter to a command
public static AddParameter ( this command, string name, object value ) : IDataParameter
command this Command to add parameter to
name string Name of the parameter
value object Value (will be changed to DBNull.Value automatically if it's null).
Результат IDataParameter
Пример #1
0
        public void do_not_allow_name_to_be_null()
        {
            var    sut    = new FakeCommand();
            Action actual = () => CommandExtensions.AddParameter(sut, null, "arne");

            actual.ShouldThrow <ArgumentNullException>();
        }
        public void cant_operate_if_supplied_argument_do_not_specify_a_name()
        {
            var    sut    = new FakeCommand();
            Action actual = () => CommandExtensions.AddParameter(sut, null, "arne");

            actual.Should().Throw <ArgumentNullException>();
        }
Пример #3
0
        public void convert_null_value_to_dbnull()
        {
            var sut = new FakeCommand();

            CommandExtensions.AddParameter(sut, "name", null);

            sut.Parameters[0].Value.Should().Be(DBNull.Value);
        }
Пример #4
0
        public void add_created_parameter_to_command()
        {
            var sut = new FakeCommand();

            CommandExtensions.AddParameter(sut, "name", "arne");

            sut.Parameters[0].Value.Should().Be("arne");
            sut.Parameters[0].ParameterName.Should().Be("name");
        }