XpoDefault.GetConnectionPoolString(String, Int32, Int32) Method
Gets a connection pool’s connection string based on a specified standard connection string, pool capacity, and connection limit.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v18.2.dll
Declaration
public static string GetConnectionPoolString(
string connectionString,
int poolSize,
int maxConnections
)
Parameters
Name | Type | Description |
---|---|---|
connectionString | String | A String value which specifies the parameters required to establish a connection. |
poolSize | Int32 | A connection pool’s capacity (the number of connections to be made available within the pool). If null (Nothing in Visual Basic) is passed as this parameter, the default value (8) is used. If a negative number is passed as this parameter, the pool capacity is unrestricted. |
maxConnections | Int32 | The total number of connections to be established, including the poolSize. If null (Nothing in Visual Basic) or negative number is passed as this parameter, the connection limit is considered unspecified. If the maxConnections is less than the poolSize, the maxConnections is assumed be equal to the poolSize. |
Returns
Type | Description |
---|---|
String | A String value which specifies the parameters needed to establish a connection pool’s connection. |
Remarks
Note
Any connection that is not pooled will be disposed of once a query for which the connection is established, has been executed.
Example:
string connectionString = "Your connection string";
// Here, 2 is the number of connections in a pool; 1 connection is not pooled.
// Total is 3 - the maximum number of connections to be established.
string connectionPoolString = XpoDefault.GetConnectionPoolString(connectionString, 2, 3);
IDataStore dataStore = XpoDefault.GetConnectionProvider(connectionPoolString,
AutoCreateOption.DatabaseAndSchema);
XPDictionary dictionary = new ReflectionDictionary();
// ...
XpoDefault.DataLayer = new ThreadSafeDataLayer(dictionary, dataStore);
XpoDefault.Session = null;