Class NpgsqlServiceCollectionExtensions
Extension method for setting up Npgsql services in an
Inheritance
Namespace: Microsoft.Extensions.DependencyInjection
Assembly: Npgsql.DependencyInjection.dll
Syntax
public static class NpgsqlServiceCollectionExtensions
Methods
| Improve this Doc View SourceAddMultiHostNpgsqlDataSource(IServiceCollection, string, Action<NpgsqlDataSourceBuilder>, ServiceLifetime, ServiceLifetime)
Registers an NpgsqlMultiHostDataSource and an NpgsqlConnection in the
Declaration
public static IServiceCollection AddMultiHostNpgsqlDataSource(this IServiceCollection serviceCollection, string connectionString, Action<NpgsqlDataSourceBuilder> dataSourceBuilderAction, ServiceLifetime connectionLifetime = null, ServiceLifetime dataSourceLifetime = null)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | serviceCollection | The |
string | connectionString | An Npgsql connection string. |
Action<><NpgsqlDataSourceBuilder> | dataSourceBuilderAction | An action to configure the NpgsqlDataSourceBuilder for further customizations of the NpgsqlDataSource. |
ServiceLifetime | connectionLifetime | The lifetime with which to register the NpgsqlConnection in the container.
Defaults to |
ServiceLifetime | dataSourceLifetime | The lifetime with which to register the NpgsqlDataSource service in the container.
Defaults to |
Returns
Type | Description |
---|---|
IServiceCollection | The same service collection so that multiple calls can be chained. |
AddMultiHostNpgsqlDataSource(IServiceCollection, string, ServiceLifetime, ServiceLifetime)
Registers an NpgsqlMultiHostDataSource and an NpgsqlConnection in the
Declaration
public static IServiceCollection AddMultiHostNpgsqlDataSource(this IServiceCollection serviceCollection, string connectionString, ServiceLifetime connectionLifetime = null, ServiceLifetime dataSourceLifetime = null)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | serviceCollection | The |
string | connectionString | An Npgsql connection string. |
ServiceLifetime | connectionLifetime | The lifetime with which to register the NpgsqlConnection in the container.
Defaults to |
ServiceLifetime | dataSourceLifetime | The lifetime with which to register the NpgsqlDataSource service in the container.
Defaults to |
Returns
Type | Description |
---|---|
IServiceCollection | The same service collection so that multiple calls can be chained. |
AddMultiHostNpgsqlSlimDataSource(IServiceCollection, string, Action<NpgsqlSlimDataSourceBuilder>, ServiceLifetime, ServiceLifetime)
Registers an NpgsqlMultiHostDataSource and an NpgsqlConnection in the
Declaration
public static IServiceCollection AddMultiHostNpgsqlSlimDataSource(this IServiceCollection serviceCollection, string connectionString, Action<NpgsqlSlimDataSourceBuilder> dataSourceBuilderAction, ServiceLifetime connectionLifetime = null, ServiceLifetime dataSourceLifetime = null)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | serviceCollection | The |
string | connectionString | An Npgsql connection string. |
Action<><NpgsqlSlimDataSourceBuilder> | dataSourceBuilderAction | An action to configure the NpgsqlDataSourceBuilder for further customizations of the NpgsqlDataSource. |
ServiceLifetime | connectionLifetime | The lifetime with which to register the NpgsqlConnection in the container.
Defaults to |
ServiceLifetime | dataSourceLifetime | The lifetime with which to register the NpgsqlDataSource service in the container.
Defaults to |
Returns
Type | Description |
---|---|
IServiceCollection | The same service collection so that multiple calls can be chained. |
AddMultiHostNpgsqlSlimDataSource(IServiceCollection, string, ServiceLifetime, ServiceLifetime)
Registers an NpgsqlMultiHostDataSource and an NpgsqlConnection in the
Declaration
public static IServiceCollection AddMultiHostNpgsqlSlimDataSource(this IServiceCollection serviceCollection, string connectionString, ServiceLifetime connectionLifetime = null, ServiceLifetime dataSourceLifetime = null)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | serviceCollection | The |
string | connectionString | An Npgsql connection string. |
ServiceLifetime | connectionLifetime | The lifetime with which to register the NpgsqlConnection in the container.
Defaults to |
ServiceLifetime | dataSourceLifetime | The lifetime with which to register the NpgsqlDataSource service in the container.
Defaults to |
Returns
Type | Description |
---|---|
IServiceCollection | The same service collection so that multiple calls can be chained. |
AddNpgsqlDataSource(IServiceCollection, string, Action<NpgsqlDataSourceBuilder>, ServiceLifetime, ServiceLifetime)
Registers an NpgsqlDataSource and an NpgsqlConnection in the
Declaration
public static IServiceCollection AddNpgsqlDataSource(this IServiceCollection serviceCollection, string connectionString, Action<NpgsqlDataSourceBuilder> dataSourceBuilderAction, ServiceLifetime connectionLifetime = null, ServiceLifetime dataSourceLifetime = null)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | serviceCollection | The |
string | connectionString | An Npgsql connection string. |
Action<><NpgsqlDataSourceBuilder> | dataSourceBuilderAction | An action to configure the NpgsqlDataSourceBuilder for further customizations of the NpgsqlDataSource. |
ServiceLifetime | connectionLifetime | The lifetime with which to register the NpgsqlConnection in the container.
Defaults to |
ServiceLifetime | dataSourceLifetime | The lifetime with which to register the NpgsqlDataSource service in the container.
Defaults to |
Returns
Type | Description |
---|---|
IServiceCollection | The same service collection so that multiple calls can be chained. |
AddNpgsqlDataSource(IServiceCollection, string, ServiceLifetime, ServiceLifetime)
Registers an NpgsqlDataSource and an NpgsqlConnection in the
Declaration
public static IServiceCollection AddNpgsqlDataSource(this IServiceCollection serviceCollection, string connectionString, ServiceLifetime connectionLifetime = null, ServiceLifetime dataSourceLifetime = null)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | serviceCollection | The |
string | connectionString | An Npgsql connection string. |
ServiceLifetime | connectionLifetime | The lifetime with which to register the NpgsqlConnection in the container.
Defaults to |
ServiceLifetime | dataSourceLifetime | The lifetime with which to register the NpgsqlDataSource service in the container.
Defaults to |
Returns
Type | Description |
---|---|
IServiceCollection | The same service collection so that multiple calls can be chained. |
AddNpgsqlSlimDataSource(IServiceCollection, string, Action<NpgsqlSlimDataSourceBuilder>, ServiceLifetime, ServiceLifetime)
Registers an NpgsqlDataSource and an NpgsqlConnection in the
Declaration
public static IServiceCollection AddNpgsqlSlimDataSource(this IServiceCollection serviceCollection, string connectionString, Action<NpgsqlSlimDataSourceBuilder> dataSourceBuilderAction, ServiceLifetime connectionLifetime = null, ServiceLifetime dataSourceLifetime = null)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | serviceCollection | The |
string | connectionString | An Npgsql connection string. |
Action<><NpgsqlSlimDataSourceBuilder> | dataSourceBuilderAction | An action to configure the NpgsqlSlimDataSourceBuilder for further customizations of the NpgsqlDataSource. |
ServiceLifetime | connectionLifetime | The lifetime with which to register the NpgsqlConnection in the container.
Defaults to |
ServiceLifetime | dataSourceLifetime | The lifetime with which to register the NpgsqlDataSource service in the container.
Defaults to |
Returns
Type | Description |
---|---|
IServiceCollection | The same service collection so that multiple calls can be chained. |
AddNpgsqlSlimDataSource(IServiceCollection, string, ServiceLifetime, ServiceLifetime)
Registers an NpgsqlDataSource and an NpgsqlConnection in the
Declaration
public static IServiceCollection AddNpgsqlSlimDataSource(this IServiceCollection serviceCollection, string connectionString, ServiceLifetime connectionLifetime = null, ServiceLifetime dataSourceLifetime = null)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | serviceCollection | The |
string | connectionString | An Npgsql connection string. |
ServiceLifetime | connectionLifetime | The lifetime with which to register the NpgsqlConnection in the container.
Defaults to |
ServiceLifetime | dataSourceLifetime | The lifetime with which to register the NpgsqlDataSource service in the container.
Defaults to |
Returns
Type | Description |
---|---|
IServiceCollection | The same service collection so that multiple calls can be chained. |