How are subliminal connections with a pen?

In Nhibernate, you start a session by creating it during BeginRequest and closing EndRequest

public class Global: System.Web.HttpApplication
{
    public static ISessionFactory SessionFactory = CreateSessionFactory();

    protected static ISessionFactory CreateSessionFactory()
    {
        return new Configuration()
            .Configure(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "hibernate.cfg.xml"))
            .BuildSessionFactory();
    }

    public static ISession CurrentSession
    {
        get{ return (ISession)HttpContext.Current.Items["current.session"]; }
        set { HttpContext.Current.Items["current.session"] = value; }
    }

    protected void Global()
    {
        BeginRequest += delegate
        {
            CurrentSession = SessionFactory.OpenSession();
        };
        EndRequest += delegate
        {
            if(CurrentSession != null)
                CurrentSession.Dispose();
        };
    }
}

What is equivalent in subsonic?

As I understand it, Nhibernate will close all connections on endrequest.

Reason: While removing some legacy codes in a Subsonic project, I get a lot of MySQL timeouts, assuming the code doesn't close the connections

MySql.Data.MySqlClient.MySqlException: : . , . , , . . : , 11 . 2009 05:26:05 GMT System.Web.HttpUnhandledException: 'System.Web.HttpUnhandledException' . --- > MySql.Data.MySqlClient.MySqlException: : . , . , , . . MySql.Data.MySqlClient.MySqlPool.GetConnection() MySql.Data.MySqlClient.MySqlConnection.Open() SubSonic.MySqlDataProvider.CreateConnection(String newConnectionString) SubSonic.MySqlDataProvider.CreateConnection() SubSonic.AutomaticConnectionScope..ctor(DataProvider ) SubSonic.MySqlDataProvider.GetReader(QueryCommand qry) SubSonic.DataService.GetReader(QueryCommand cmd) SubSonic.ReadOnlyRecord`1.LoadByParam(String columnName, Object paramValue)

<connectionStrings>
    <add name="xx" connectionString="Data Source=xx.net; Port=3306; Database=db; UID=dbuid; PWD=xx;Pooling=true;Max Pool Size=12;Min Pool Size=2;Connection Lifetime=60" />
  </connectionStrings>
+3
2

, "SharedDbConnectionScope". - MySQL - , MySQL .

, , - bam. ConnectionPool.

, .

+5

, SubSonic . Javascript, 2 , , , , DataReader. , , script 160 . , SubSonic ( IDataReader , ).

+4

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


All Articles