Exemplo n.º 1
0
        private string GetParamName(int index)
        {
            IParameterNameGenerator parameterNameGenerator = DatabaseConnection.CurrentConnection.CreateParameterNameGenerator();

            for (int i = 0; i < index; i++)
            {
                parameterNameGenerator.GetNextParameterName();
            }
            return(parameterNameGenerator.GetNextParameterName());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a parameter to the sql statement
        /// </summary>
        /// <param name="obj">The parameter to add</param>
        public void AddParameterToStatement(object obj)
        {
            string paramName = _gen.GetNextParameterName();

            this.AddParameter(paramName, obj);
            this.Statement.Append(paramName);
        }
Exemplo n.º 3
0
        public void TestCreateParameterNameGenerator()
        {
            //---------------Set up test pack-------------------
            IDatabaseConnection databaseConnection = new DatabaseConnectionMySql("", "");
            //---------------Assert PreConditions---------------
            //---------------Execute Test ----------------------
            IParameterNameGenerator generator = databaseConnection.CreateParameterNameGenerator();

            //---------------Test Result -----------------------
            Assert.IsNotNull(generator);
            Assert.AreEqual("?Param0", generator.GetNextParameterName());
            //---------------Tear Down -------------------------
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds the specified property value as a parameter
        /// </summary>
        /// <param name="prop">The business object property</param>
        private void AddPropToInsertStatement(BOProp prop)
        {
            if (!_firstField)
            {
                _dbFieldList.Append(", ");
                _dbValueList.Append(", ");
            }
            _dbFieldList.Append(_connection.SqlFormatter.DelimitField(prop.DatabaseFieldName));
            string paramName = _gen.GetNextParameterName();

            _dbValueList.Append(paramName);
            _insertSql.AddParameter(paramName, prop.Value, prop.PropertyType);
            _firstField = false;
        }