public void AddParameter()
        {
            InsertCommandBuilder builder = new InsertCommandBuilder(TestSettings.CreateConnection());

            builder.TableName = "Table1";
            builder.AddParameter("p1", DbType.Date);
            builder.AddParameter("p2", typeof(DateTime));
            builder.AddParameter("p3", 1);
            builder.AddParameter("p4", "par4", true);
            IDbCommand command = builder.Build();

            Assert.AreEqual(command.CommandType, CommandType.Text);
            Assert.IsNotNull(command.Parameters["@p1"]);
            Assert.IsNotNull(command.Parameters["@p2"]);
            Assert.IsNotNull(command.Parameters["@p3"]);
            Assert.IsNotNull(command.Parameters["@par4"]);
        }
Exemple #2
0
        public void  Test()
        {
            DBConnection         connection = TestSettings.CreateConnection();
            InsertCommandBuilder builder    = new InsertCommandBuilder(connection);

            builder.TableName = "Table1";
            builder.AddParameter("value", "1");
            IDbCommand command = builder.Build();

            Assert.IsNotNull(command);
            Assert.AreEqual(1, connection.ExecuteNonQuery(command));
        }
Exemple #3
0
        /// <summary>
        /// Creates the insert command.
        /// </summary>
        /// <returns></returns>
        private void CreateInsertCommand()
        {
            var builder = new InsertCommandBuilder(_connection.Factory);

            builder.TableName = TableName;

            foreach (PropertyInfo field in _fields)
            {
                builder.AddParameter(field.Name, field.PropertyType);
            }


            _insertCommand = builder.Build();
            //insertCommand.Prepare();
        }
Exemple #4
0
        private SendParameter PreparePrimitive(Type parameterType)
        {
            var builder = new CreateTableCommandBuilder(_connection.Factory)
            {
                TableName = TableName
            };

            builder.AddColumn("value", parameterType);
            _connection.ExecuteNonQuery(builder.Build());

            var builderInsert = new InsertCommandBuilder(_connection.Factory)
            {
                TableName = TableName
            };

            builderInsert.AddParameter("value", parameterType);
            _insertCommand = builderInsert.Build();
            //insertCommand.Prepare();

            return(SendPrimitive);
        }