Eventuous / eventuous

Event Sourcing library for .NET
https://eventuous.dev
Apache License 2.0
430 stars 69 forks source link

Enable custom configuration of NpgsqlDataSourceBuilder when using AddEventuousPostgres #323

Closed gius closed 1 month ago

gius commented 3 months ago

Is your feature request related to a problem? Please describe. When using PostgreSQL projectors along with NodaTime, one needs to configure NpgsqlDataSourceBuilder. However, when initializing Postgres using AddEventuousPostgres, there is no way to customize the initialization. We could manually register NpgsqlDataSource, but that would require to repeat all the additional setup that is done by AddEventuousPostgres.

Describe the solution you'd like Add a way to access NpgsqlDataSourceBuilder created by AddNpgsqlDataSourceCore.

For example, with EF, you can configure the builder as follows:

services.AddDbContext<PostregressDbContext>((provider, options) =>
{
    options.UseNpgsql(connectionString.Value, b => b.UseNodaTime());
});

Describe alternatives you've considered Manually registering NpgsqlDataSource.

Additional context NodaTime + PostgreSQL

gius commented 3 months ago

A workaround is to configure the mappings globally. However, the function is Obsolete.

NpgsqlConnection.GlobalTypeMapper.UseNodaTime();