Exemple #1
0
        public DbCommand AsCommonCommand(DbConnection conn, DbTransaction trans)
        {
            StringBuilder cmd = this._cmd;

            for (int i = 0; i < _pms.Count; i++)
            {
                if (_pms[i] is Func)
                {
                    cmd = cmd.Replace(_pms.GetName(i), (_pms[i] as Func).Content);
                    _pms.RemoveAt(i--);
                }
            }
            DbCommand dbcmd = _dbprovider.Provider.CreateCommand();

            dbcmd.CommandText = cmd.ToString();
            dbcmd.Connection  = conn;
            dbcmd.Transaction = trans;
            foreach (NameValue i in _pms)
            {
                DbParameter param = _dbprovider.Provider.CreateParameter();
                param.ParameterName = i.Name;
                param.Value         = i.Value;
                (dbcmd.Parameters as IList).Add(param);
            }
            return(dbcmd);
        }