Exemple #1
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);
        }
Exemple #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>
        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);
        }