Search Results for

    Show / Hide Table of Contents

    Class NpgsqlServiceCollectionExtensions

    Extension method for setting up Npgsql services in an .

    Inheritance
    object
    NpgsqlServiceCollectionExtensions
    Namespace: Microsoft.Extensions.DependencyInjection
    Assembly: Npgsql.DependencyInjection.dll
    Syntax
    public static class NpgsqlServiceCollectionExtensions

    Methods

    | Improve this Doc View Source

    AddMultiHostNpgsqlDataSource(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 to add services to.

    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.

    | Improve this Doc View Source

    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 to add services to.

    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.

    | Improve this Doc View Source

    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 to add services to.

    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.

    | Improve this Doc View Source

    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 to add services to.

    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.

    | Improve this Doc View Source

    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 to add services to.

    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.

    | Improve this Doc View Source

    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 to add services to.

    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.

    | Improve this Doc View Source

    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 to add services to.

    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.

    | Improve this Doc View Source

    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 to add services to.

    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.

    • Improve this Doc
    • View Source
    In This Article
    Back to top © Copyright 2023 The Npgsql Development Team