Table of Contents

Class ConfigurationExtensions

Namespace
Excalibur.Data.SqlServer
Assembly
Excalibur.Data.SqlServer.dll

Provides extension methods for retrieving SQL connections and SQL database instances using configuration settings.

public static class ConfigurationExtensions
Inheritance
ConfigurationExtensions
Inherited Members

Methods

GetSqlConnection(IConfiguration, string)

Retrieves and opens a SqlConnection based on the specified connection name in the configuration.

public static SqlConnection GetSqlConnection(this IConfiguration configuration, string connectionName)

Parameters

configuration IConfiguration

The configuration object containing connection strings.

connectionName string

The name of the connection string in the configuration.

Returns

SqlConnection

An open SqlConnection instance.

Exceptions

ArgumentException

Thrown if connectionName is null, empty, or whitespace.

InvalidConfigurationException

Thrown if the connection string is not found or is empty in the configuration.

GetSqlDb(IConfiguration, string)

Retrieves a factory function for creating a SqlDb instance based on the specified connection name in the configuration.

public static Func<SqlDb> GetSqlDb(this IConfiguration configuration, string connectionName)

Parameters

configuration IConfiguration

The configuration object containing connection strings.

connectionName string

The name of the connection string in the configuration.

Returns

Func<SqlDb>

A factory function that, when invoked, returns a SqlDb instance initialized with an open SQL connection.

Exceptions

ArgumentException

Thrown if connectionName is null, empty, or whitespace.

InvalidConfigurationException

Thrown if the connection string is not found or is empty in the configuration.