Пример #1
0
        /// <summary>
        /// 获取当前事务
        /// </summary>
        /// <returns></returns>
        OracleTransaction GetTransaction()
        {
            DbTransaction trans;

            if (MyTransactionScope1.TryGetTransaction(DBConnString, out trans))
            {
                if (trans == null)
                {
                    throw new Exception("当前事务环境还未创建事务");
                }
                return(trans as OracleTransaction);
            }
            return(null);
        }
Пример #2
0
        /// <summary>
        /// 获取数据库连接
        /// </summary>
        /// <returns></returns>
        protected OracleConnection GetConnection()
        {
            DbConnection conn;

            if (MyTransactionScope1.TryGetDbConnection(DBConnString, out conn))
            {
                if (conn == null)
                {
                    conn = new OracleConnection(DBConnString);
                    MyTransactionScope1.TryJoinToCurrentTransaction(DBConnString, conn);
                }
                return(conn as OracleConnection);
            }
            else
            {
                OracleConnection sqlConn = new OracleConnection(DBConnString);
                sqlConn.Open();
                return(sqlConn);
            }
        }