Beispiel #1
0
        private void ResetCommands()
        {
            _fixedCommands.Clear();
            int indexer = 0;

            foreach (var qry in _queries)
            {
                QueryCommand cmd         = qry.GetCommand();
                string       commandText = cmd.CommandSql;
                foreach (var p in cmd.Parameters)
                {
                    string oldParamName = p.ParameterName;
                    p.ParameterName = _provider.ParameterPrefix + indexer;

                    commandText = System.Text.RegularExpressions.Regex.Replace(commandText, oldParamName + @"\b", _provider.ParameterPrefix + "p" + indexer);
                    indexer++;
                }
                cmd.CommandSql = commandText.Replace(_provider.ParameterPrefix + "p", _provider.ParameterPrefix);
                _fixedCommands.Add(cmd);
            }
        }
Beispiel #2
0
        public QueryCommand GetCommand()
        {
            string       sql = BuildSqlStatement();
            QueryCommand cmd = new QueryCommand(sql, _provider);

            //add in the commands
            foreach (InsertSetting s in Inserts)
            {
                if (!s.IsPrimaryKey)
                {
                    QueryParameter p = new QueryParameter
                    {
                        ParameterName  = s.ParameterName,
                        ParameterValue = s.Value ?? DBNull.Value,
                        DataType       = s.DataType
                    };
                    cmd.Parameters.Add(p);
                }
            }
            return(cmd);
        }
Beispiel #3
0
 /// <summary>
 /// Queues a query for use in a transaction.
 /// </summary>
 /// <param name="cmd">The CMD.</param>
 public void QueueForTransaction(QueryCommand cmd)
 {
     _fixedCommands.Add(cmd);
 }
Beispiel #4
0
 public CodingHorror(IDataProvider provider, string sql)
 {
     _provider = provider;
     _command  = new QueryCommand(sql, _provider);
 }
Beispiel #5
0
 public CodingHorror(IDataProvider provider, string sql, params object[] values)
 {
     _provider = provider;
     _command  = new QueryCommand(sql, _provider);
     LoadCommandParams(_command, values);
 }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CodingHorror"/> class.
 /// </summary>
 /// <param name="sql">The SQL.</param>
 /// <param name="values">The values.</param>
 public CodingHorror(string sql, params object[] values)
 {
     _provider = ProviderFactory.GetProvider();
     _command  = new QueryCommand(sql, _provider);
     LoadCommandParams(_command, values);
 }
Beispiel #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CodingHorror"/> class.
 /// Warning: This method assumes the default provider is intended.
 /// Call InlineQuery(string providerName) if this is not the case.
 /// </summary>
 /// <param name="sql">The SQL.</param>
 public CodingHorror(string sql)
 {
     _provider = ProviderFactory.GetProvider();
     _command  = new QueryCommand(sql, _provider);
 }
Beispiel #8
0
 internal void SetConstraintParams(QueryCommand cmd)
 {
     //loop the constraints and add the values
     SetConstraintParams(this, cmd);
 }