DataConnector
ADO.NET provider for OData / Connection Pooling
In This Topic
    Connection Pooling
    In This Topic

    ADO.NET provider for OData implements connection pooling to reduce the efforts of repeatedly opening and closing connections. A connection pool is a cache of database connections maintained where user can reuse existing active connections with the same connection string instead of creating new connections when a request is made to the database.

    Connection pools are used to enhance the performance of executing commands on a database. The provider by default supports pooling as the Pooling property is set to True. However, pooling can be disabled by setting this property to false.

    The code example below demonstrates the implementation of connection pooling in DataConnector for OData.

    //With Pool: It saves your time as connection object is already available in the pool
    for (int i = 0; i < 1000; i++)
    {
      C1ODataConnection c = new C1ODataConnection($@"{testUrl};Pooling=true;");
      c.Open();//Soft connections are build
      //Perform Your Operation  
      c.Close();//Conncetion moved to connection pool
    }
                       
    //Without Pool:
    for (int i = 0; i < 1000; i++)
    {
       C1ODataConnection c = new C1ODataConnection($@"{testUrl};Pooling=false;"); //By default pooling is true
       c.Open();//Every time hard connections are build
       //Perform Your Operation  
       c.Close();//Connection object move to garbage collection
    }