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
servicesIServiceCollectionThe service collection to add the database connection to.
configurationIConfigurationThe configuration instance used to bind to DbConnectionOptions.
Returns
- IServiceCollection
The updated service collection.
Type Parameters
TRepositoryThe 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
servicesIServiceCollectionThe service collection to add the database connection to.
configureAction<DbConnectionOptions>An action to configure the DbConnectionOptions.
Returns
- IServiceCollection
The updated service collection.
Type Parameters
TRepositoryThe 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
servicesIServiceCollectionThe service collection to add the database connection to.
configurationSectionPathstringThe configuration section path used to bind to DbConnectionOptions.
Returns
- IServiceCollection
The updated service collection.
Type Parameters
TRepositoryThe 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
servicesIServiceCollectionThe service collection to add the database connection to.
databaseNamestringThe name of the database.
configurationIConfigurationThe configuration instance used to bind to DbConnectionOptions.
Returns
- IServiceCollection
The updated service collection.
Type Parameters
TRepositoryThe 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
servicesIServiceCollectionThe service collection to add the database connection to.
databaseNamestringThe name of the database.
configureAction<DbConnectionOptions>An action to configure the DbConnectionOptions.
Returns
- IServiceCollection
The updated service collection.
Type Parameters
TRepositoryThe 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
servicesIServiceCollectionThe service collection to add the database connection to.
databaseNamestringThe name of the database.
configurationSectionPathstringThe configuration section path used to bind to DbConnectionOptions.
Returns
- IServiceCollection
The updated service collection.
Type Parameters
TRepositoryThe type of the repository that derives from Repository.