Table of Contents

Class ServiceCollectionExtensions

Namespace
IceCoffee.Db4Net.DependencyInjection
Assembly
IceCoffee.Db4Net.DependencyInjection.dll

Provides extension methods for registering database connections and repositories.

public static class ServiceCollectionExtensions
Inheritance
ServiceCollectionExtensions
Inherited Members

Methods

AddDbConnection<TRepository>(IServiceCollection, IConfiguration)

Configures and registers a database connection using an IConfiguration instance.

public static IServiceCollection AddDbConnection<TRepository>(this IServiceCollection services, IConfiguration configuration) where TRepository : Repository

Parameters

services IServiceCollection

The service collection to add the database connection to.

configuration IConfiguration

The configuration instance used to bind to DbConnectionOptions.

Returns

IServiceCollection

The updated service collection.

Type Parameters

TRepository

The type of the repository that derives from Repository.

AddDbConnection<TRepository>(IServiceCollection, Action<DbConnectionOptions>)

Configures and registers a database connection using the specified configuration action.

public static IServiceCollection AddDbConnection<TRepository>(this IServiceCollection services, Action<DbConnectionOptions> configure) where TRepository : Repository

Parameters

services IServiceCollection

The service collection to add the database connection to.

configure Action<DbConnectionOptions>

An action to configure the DbConnectionOptions.

Returns

IServiceCollection

The updated service collection.

Type Parameters

TRepository

The type of the repository that derives from Repository.

AddDbConnection<TRepository>(IServiceCollection, string)

Configures and registers a database connection using a configuration section path.

public static IServiceCollection AddDbConnection<TRepository>(this IServiceCollection services, string configurationSectionPath) where TRepository : Repository

Parameters

services IServiceCollection

The service collection to add the database connection to.

configurationSectionPath string

The configuration section path used to bind to DbConnectionOptions.

Returns

IServiceCollection

The updated service collection.

Type Parameters

TRepository

The type of the repository that derives from Repository.

AddDbConnection<TRepository>(IServiceCollection, string, IConfiguration)

Configures and registers a database connection with a specified database name using an IConfiguration instance.

public static IServiceCollection AddDbConnection<TRepository>(this IServiceCollection services, string databaseName, IConfiguration configuration) where TRepository : Repository

Parameters

services IServiceCollection

The service collection to add the database connection to.

databaseName string

The name of the database.

configuration IConfiguration

The configuration instance used to bind to DbConnectionOptions.

Returns

IServiceCollection

The updated service collection.

Type Parameters

TRepository

The type of the repository that derives from Repository.

AddDbConnection<TRepository>(IServiceCollection, string, Action<DbConnectionOptions>)

Configures and registers a database connection with a specified database name using the provided configuration action.

public static IServiceCollection AddDbConnection<TRepository>(this IServiceCollection services, string databaseName, Action<DbConnectionOptions> configure) where TRepository : Repository

Parameters

services IServiceCollection

The service collection to add the database connection to.

databaseName string

The name of the database.

configure Action<DbConnectionOptions>

An action to configure the DbConnectionOptions.

Returns

IServiceCollection

The updated service collection.

Type Parameters

TRepository

The type of the repository that derives from Repository.

AddDbConnection<TRepository>(IServiceCollection, string, string)

Configures and registers a database connection with a specified database name using a configuration section path.

public static IServiceCollection AddDbConnection<TRepository>(this IServiceCollection services, string databaseName, string configurationSectionPath) where TRepository : Repository

Parameters

services IServiceCollection

The service collection to add the database connection to.

databaseName string

The name of the database.

configurationSectionPath string

The configuration section path used to bind to DbConnectionOptions.

Returns

IServiceCollection

The updated service collection.

Type Parameters

TRepository

The type of the repository that derives from Repository.