Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
0
 public CodingHorror(IDataProvider provider, string sql)
 {
     _provider = provider;
     _command  = new QueryCommand(sql, _provider);
 }
Ejemplo n.º 4
0
 public CodingHorror(IDataProvider provider, string sql, params object[] values)
 {
     _provider = provider;
     _command  = new QueryCommand(sql, _provider);
     LoadCommandParams(_command, values);
 }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
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);
 }
Ejemplo n.º 7
0
 internal void SetConstraintParams(QueryCommand cmd)
 {
     //loop the constraints and add the values
     SetConstraintParams(this, cmd);
 }