ShardMap.OpenConnectionForKey Method

Definition

Overloads

OpenConnectionForKey<TKey>(TKey, String)

Opens a regular System.Data.SqlClient.SqlConnection to the shard to which the specified key value is mapped, with Validate.

OpenConnectionForKey<TKey>(TKey, String, ConnectionOptions)

Opens a regular System.Data.SqlClient.SqlConnection to the shard to which the specified key value is mapped.

OpenConnectionForKey<TKey>(TKey, String)

Opens a regular System.Data.SqlClient.SqlConnection to the shard to which the specified key value is mapped, with Validate.

public System.Data.SqlClient.SqlConnection OpenConnectionForKey<TKey> (TKey key, string connectionString);
member this.OpenConnectionForKey : 'Key * string -> System.Data.SqlClient.SqlConnection
Public Function OpenConnectionForKey(Of TKey) (key As TKey, connectionString As String) As SqlConnection

Type Parameters

TKey

Type of the key.

Parameters

key
TKey

Input key value.

connectionString
System.String

Connection string with credential information such as SQL Server credentials or Integrated Security settings. The hostname of the server and the database name for the shard are obtained from the lookup operation for key.

Returns

System.Data.SqlClient.SqlConnection

An opened SqlConnection.

Remarks

Note that the System.Data.SqlClient.SqlConnection object returned by this call is not protected against transient faults. Callers should follow best practices to protect the connection against transient faults in their application code, e.g., by using the transient fault handling functionality in the Enterprise Library from Microsoft Patterns and Practices team. This call only works if there is a single default mapping.

Applies to

OpenConnectionForKey<TKey>(TKey, String, ConnectionOptions)

Opens a regular System.Data.SqlClient.SqlConnection to the shard to which the specified key value is mapped.

public System.Data.SqlClient.SqlConnection OpenConnectionForKey<TKey> (TKey key, string connectionString, Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ConnectionOptions options);
member this.OpenConnectionForKey : 'Key * string * Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ConnectionOptions -> System.Data.SqlClient.SqlConnection
Public Function OpenConnectionForKey(Of TKey) (key As TKey, connectionString As String, options As ConnectionOptions) As SqlConnection

Type Parameters

TKey

Type of the key.

Parameters

key
TKey

Input key value.

connectionString
System.String

Connection string with credential information such as SQL Server credentials or Integrated Security settings. The hostname of the server and the database name for the shard are obtained from the lookup operation for key.

options
ConnectionOptions

Options for validation operations to perform on opened connection.

Returns

System.Data.SqlClient.SqlConnection

An opened SqlConnection.

Remarks

Note that the System.Data.SqlClient.SqlConnection object returned by this call is not protected against transient faults. Callers should follow best practices to protect the connection against transient faults in their application code, e.g., by using the transient fault handling functionality in the Enterprise Library from Microsoft Patterns and Practices team. This call only works if there is a single default mapping.

Applies to