ShardMap.OpenConnectionForKeyAsync Method

Definition

Overloads

OpenConnectionForKeyAsync<TKey>(TKey, String)

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

OpenConnectionForKeyAsync<TKey>(TKey, String, ConnectionOptions)

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

OpenConnectionForKeyAsync<TKey>(TKey, String)

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

public System.Threading.Tasks.Task<System.Data.SqlClient.SqlConnection> OpenConnectionForKeyAsync<TKey> (TKey key, string connectionString);
member this.OpenConnectionForKeyAsync : 'Key * string -> System.Threading.Tasks.Task<System.Data.SqlClient.SqlConnection>
Public Function OpenConnectionForKeyAsync(Of TKey) (key As TKey, connectionString As String) As Task(Of 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.Threading.Tasks.Task<System.Data.SqlClient.SqlConnection>

A Task encapsulating 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

OpenConnectionForKeyAsync<TKey>(TKey, String, ConnectionOptions)

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

public System.Threading.Tasks.Task<System.Data.SqlClient.SqlConnection> OpenConnectionForKeyAsync<TKey> (TKey key, string connectionString, Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ConnectionOptions options);
member this.OpenConnectionForKeyAsync : 'Key * string * Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ConnectionOptions -> System.Threading.Tasks.Task<System.Data.SqlClient.SqlConnection>
Public Function OpenConnectionForKeyAsync(Of TKey) (key As TKey, connectionString As String, options As ConnectionOptions) As Task(Of 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.Threading.Tasks.Task<System.Data.SqlClient.SqlConnection>

A Task encapsulating 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