Getting a connection string from nHibernate returns a string WITHOUT a password

I need to access the database directly in the nhibernate application. I am trying to get the connection string as follows:

    using (SqlConnection conn = new SqlConnection(this.session.Connection.ConnectionString))

But this will return the connection string WITHOUT a password.

Am I doing something wrong? Is there any other way to get the connection string?

+3
source share
1 answer

You can get a raw database connection (using the same connection data as NHibernate) from the NHibernate SessionFactory, for example:

Connection IDbConnection = yourSessionFactory.ConnectionProvider.GetConnection ()

+5
source

Source: https://habr.com/ru/post/1785225/


All Articles