Beispiel #1
0
        public override DbDataReader ExecuteReader(string cmd, int timeout = 0)
        {
            DbCommand command = DbDriver.CreateCommand(cmd, _connection);

            if (timeout > 0)
            {
                command.CommandTimeout = timeout;
            }

            return(command.ExecuteReader());
        }
Beispiel #2
0
        public override int ExecuteNonQuery(string cmd, int timeout = 0)
        {
            DbCommand command = DbDriver.CreateCommand(cmd, _connection);

            if (timeout > 0)
            {
                command.CommandTimeout = timeout;
            }

            return(command.ExecuteNonQuery());
        }
Beispiel #3
0
 /// <summary>
 /// Gets the example query meta data.
 /// </summary>
 /// <param name="dbDriver">The driver.</param>
 /// <param name="sampleSQL">The sample SQL.</param>
 /// <param name="metadataSetting">The metadata setting.</param>
 /// <param name="contextAttributes">The context attributes.</param>
 /// <returns></returns>
 private static QueryMetaData GetExampleQueryMetaData(
     DbDriver dbDriver,
     string sampleSQL,
     ColumnSettings metadataSetting,
     IEnumerable<Attribute> contextAttributes)
 {
     var sampleSQLFragments = PlaceholderParser.ParsePlaceholder(sampleSQL);
     using (var dbCommand = dbDriver.CreateCommand(sampleSQLFragments, metadataSetting, contextAttributes)) {
         return dbCommand.MetaData;
     }
 }
Beispiel #4
0
 public DataCommandBuilder(DbDriver driver, bool batchMode = false, SqlGenMode mode = SqlGenMode.PreferParam)
 {
     _driver           = driver;
     _sqlDialect       = _driver.SqlDialect;
     _batchMode        = batchMode;
     _genMode          = mode;
     _maxLiteralLength = _driver.SqlDialect.MaxLiteralLength;
     _dbCommand        = _driver.CreateCommand();
     //reserve spots: #0 for batch-begin (BEGIN; in ORACLE); #2 for Begin Trans
     _sqlStrings.Add(string.Empty);
     _sqlStrings.Add(string.Empty);
 }
Beispiel #5
0
        /// <summary>
        /// Make a new pair of resources.
        /// </summary>
        /// <returns>pair of resources</returns>
        protected Pair<DbDriver, DbDriverCommand> MakeNew()
        {
            Log.Info(".MakeNew Obtaining new connection and statement");

            try {
                // Get the driver
                DbDriver dbDriver = _databaseConnectionFactory.Driver;
                // Get the command
                DbDriverCommand dbCommand = dbDriver.CreateCommand(_sqlFragments, null, _contextAttributes);

                return new Pair<DbDriver, DbDriverCommand>(dbDriver, dbCommand);
            }
            catch (DatabaseConfigException ex) {
                throw new EPException("Error obtaining connection", ex);
            }
        }