Пример #1
0
        /// <summary>
        /// Creates a new transaction/savepoint wrapper class
        /// </summary>
        /// <param name="connection">Database connection, null if it's a dummy wrapper (nested transaction without creating a savepoint)</param>
        /// <param name="savepointName">Savepoint name, null if it's a transaction instead of a savepoint</param>
        internal DBOracleTransaction(DBOracleConnectionInstance connection, string savepointName)
        {
            if ((connection is null) && (!(savepointName is null)))
            {
                throw new ArgumentNullException(nameof(connection));
            }

            Connection    = connection;
            SavepointName = savepointName;
        }
Пример #2
0
        /// <summary>
        /// Creates a disposable container with a database connection, creating a new connection if necessary
        /// </summary>
        /// <param name="connection">Database connection (null for a new connection)</param>
        /// <param name="connectionStringName">Connection string name (must not be null if connection is null)</param>
        public static DBOracleConnection Create(DBOracleConnection connection, string connectionStringName)
        {
            var newConnection = new DBOracleConnection();

            if (connection is null)
            {
                newConnection.DisposeConnection = true;
                newConnection.Connection        = DBOracleConnectionInstance.Open(connectionStringName);
            }
            else
            {
                newConnection.DisposeConnection = false;
                newConnection.Connection        = connection.Connection;
            }

            return(newConnection);
        }
Пример #3
0
        /// <summary>
        /// Creates a disposable container with a database connection, creating a new connection if necessary
        /// </summary>
        /// <param name="connection">Database connection (null for a new connection)</param>
        /// <param name="connectionStringName">Connection string name (must not be null if connection is null)</param>
        protected static T Create <T>(DBOracleConnection connection, string connectionStringName) where T : DBOracleConnection
        {
            var newConnection = (T)Activator.CreateInstance(type: typeof(T), nonPublic: true);

            if (connection is null)
            {
                newConnection.DisposeConnection = true;
                newConnection.Connection        = DBOracleConnectionInstance.Open(connectionStringName);
            }
            else
            {
                newConnection.DisposeConnection = false;
                newConnection.Connection        = connection.Connection;
            }

            return(newConnection);
        }