AspirePostgreSqlNpgsqlExtensions Methods
Class Methods 2 members
Extension methods for connecting PostgreSQL database with Npgsql client
AddKeyedNpgsqlDataSource(IHostApplicationBuilder, string, Action<NpgsqlSettings>, Action<NpgsqlDataSourceBuilder>) Section titled AddKeyedNpgsqlDataSource(IHostApplicationBuilder, string, Action<NpgsqlSettings>, Action<NpgsqlDataSourceBuilder>) extension Registers
NpgsqlDataSource as a keyed service for given name for connecting PostgreSQL database with Npgsql client. Configures health check, logging and telemetry for the Npgsql client. public static class AspirePostgreSqlNpgsqlExtensions{ public static void AddKeyedNpgsqlDataSource( this IHostApplicationBuilder builder, string name, Action<NpgsqlSettings>? configureSettings = null, Action<NpgsqlDataSourceBuilder>? configureDataSourceBuilder = null) { // ... }}Parameters
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to. name string The name of the component, which is used as the ServiceDescriptor.ServiceKey of the service and also to retrieve the connection string from the ConnectionStrings configuration section. configureSettings Action<NpgsqlSettings> optional An optional method that can be used for customizing options. It's invoked after the settings are read from the configuration. configureDataSourceBuilder Action<NpgsqlDataSourceBuilder> optional An optional delegate that can be used for customizing the NpgsqlDataSourceBuilder. Exceptions
ArgumentNullException Thrown when builder or name is null. ArgumentException Thrown if mandatory name is empty. InvalidOperationException Thrown when mandatory NpgsqlSettings.ConnectionString is not provided. Remarks
Reads the configuration from "Aspire:Npgsql:{name}" section.
AddNpgsqlDataSource(IHostApplicationBuilder, string, Action<NpgsqlSettings>, Action<NpgsqlDataSourceBuilder>) Section titled AddNpgsqlDataSource(IHostApplicationBuilder, string, Action<NpgsqlSettings>, Action<NpgsqlDataSourceBuilder>) extension Registers
NpgsqlDataSource service for connecting PostgreSQL database with Npgsql client. Configures health check, logging and telemetry for the Npgsql client. public static class AspirePostgreSqlNpgsqlExtensions{ public static void AddNpgsqlDataSource( this IHostApplicationBuilder builder, string connectionName, Action<NpgsqlSettings>? configureSettings = null, Action<NpgsqlDataSourceBuilder>? configureDataSourceBuilder = null) { // ... }}Parameters
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to. connectionName string A name used to retrieve the connection string from the ConnectionStrings configuration section. configureSettings Action<NpgsqlSettings> optional An optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration. configureDataSourceBuilder Action<NpgsqlDataSourceBuilder> optional An optional delegate that can be used for customizing the NpgsqlDataSourceBuilder. Exceptions
ArgumentNullException Thrown if mandatory builder is null. InvalidOperationException Thrown when mandatory NpgsqlSettings.ConnectionString is not provided. Remarks
Reads the configuration from "Aspire:Npgsql" section.