문제

I have .NET application with Oracle Database and NHibernate. I need to handle some "Connected" event which raised before NHibernate executed first DbCommand with currently used OracleConnection. This is due to the necessity of primary context initialization. I need to be sure that before executing any command context was initialized. Is there such a possibility in NHibernate?

P.S. I can not use Oracle ON LOGON TRIGGER for this purpose

UPD. The solution is:

public class CustomConnectionProvider : DriverConnectionProvider
    {
        public override System.Data.IDbConnection GetConnection()
        {
            var conn = (OracleConnection)base.GetConnection();
            //init context
            return conn;
        }
    }
도움이 되었습니까?

해결책

You can use a custom DriverConnectionProvider. Normally this is used to dynamically change the connection but it seems like a good fit for your scenario. Since it's responsible for creating and opening the connection, you are guaranteed that no operations have occurred before it executes.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top