4

At the heart of Petapoco.cs there is the function OpenShareConnection. I believe this cannot take advantage of the Connection Pool in SQL Azure. I am monitoring my connections and the connection count grows above the pool limit.

Anyone has done some improvements?

Here is the OpenShareConnection (from Petapoco open source):

    public void OpenSharedConnection()
    {
        if (_sharedConnectionDepth == 0)
        {                
            //read the connection string from web.config and 
            //create a new connection
            _sqlConnection = _factory.CreateConnection(); 
            _sqlConnection.ConnectionString = _connectionString;


            // Wrap this method with a retry policy.
            _sqlConnection.Open();

            _sqlConnection = OnConnectionOpened(_sqlConnection);

            if (KeepConnectionAlive)
                _sharedConnectionDepth++;       // Make sure you call Dispose
        }
        _sharedConnectionDepth++;
    }
Uri Kluk
  • 185
  • 8

1 Answers1

0

https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-connection-pooling

As far as I can see Petapoco is fighting the basic premise behind ADO connection pooling not creating a new SQLConnection(string connectionString) and then performing a .Close() method when the connection is closed.

Not surprising there are nothing but crickets chirping on this 4 yr. 9 month old question.

user3683706
  • 93
  • 1
  • 7