Exemplo n.º 1
0
        public void ExecuteTest_NonQueryCallBack()
        {
            using (var adoTemplate = OracleFactory.CreateAdoTemplate(ConnectionString))
            {
                using (var opw = new OracleParametersWrapper <string>())
                {
                    opw.SetString("COL_ID", "ID");
                    opw.SetInt("COL_INT", 0);
                    opw.SetLong("COL_LONG", 0);
                    opw.SetDouble("COL_DOUBLE", 1);
                    opw.SetDecimal("COL_DECIMAL", 1);
                    opw.SetString("COL_STRING", "empty");
                    opw.SetDateTime("COL_DATE", DateTime.Now);
                    opw.SetClob("COL_CLOB", "BIG STRING");

                    NonQueryCallBack t = new NonQueryCallBack(CommandType.Text,
                                                              SQLBuilder.BuildInsert("DUMMY_TABLE", new[]
                    {
                        "COL_ID",
                        "COL_INT",
                        "COL_LONG",
                        "COL_DOUBLE",
                        "COL_DECIMAL",
                        "COL_STRING",
                        "COL_DATE",
                        "COL_CLOB",
                    }), opw);
                    int result = adoTemplate.Execute(t);
                    if (result != 1)
                    {
                        Assert.Fail("expected 1 insert.");
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///  Executes an SQL statement and returns the number of rows affected. Insert, Update, Delete.
        /// </summary>
        /// <param name="cmdType">Text or Stored Procedure</param>
        /// <param name="cmdText">The command text (Insert, Update, Delete)</param>
        /// <param name="dbParameterSetter">The parameter setter to bind to the query</param>
        /// <returns></returns>
        public int ExecuteNonQuery(CommandType cmdType, string cmdText, IDbParameterSetter dbParameterSetter)
        {
            if (string.IsNullOrEmpty(cmdText))
            {
                throw new ArgumentNullException($"{nameof(cmdText)}: CommandText must be not null");
            }
            NonQueryCallBack t = new NonQueryCallBack(cmdType, cmdText, dbParameterSetter);

            return(Execute(t));
        }