books/backend/Books.Api/EventFlow/Extensions/ReadModelRegistrationExtensions.cs
Nicolaj Hartmann 66f6fa138d Initial commit: Books accounting system with EventFlow CQRS
Backend (.NET 10):
- EventFlow CQRS/Event Sourcing with PostgreSQL
- GraphQL.NET API with mutations and queries
- Custom ReadModelSqlGenerator for snake_case PostgreSQL columns
- Hangfire for background job processing
- Integration tests with isolated test databases

Frontend (React/Vite):
- Initial project structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 02:52:30 +01:00

30 lines
997 B
C#

using Books.Api.EventFlow.ReadModels;
using Books.Api.EventFlow.Repositories;
using EventFlow;
using EventFlow.Extensions;
using EventFlow.PostgreSql.Extensions;
using EventFlow.Sql.ReadModels;
using ReadModelSqlGenerator = Books.Api.EventFlow.Customs.ReadModelSqlGenerator;
namespace Books.Api.EventFlow.Extensions;
public static class ReadModelRegistrationExtensions
{
public static IEventFlowOptions AddReadModels(this IEventFlowOptions options)
{
return options
.UsePostgreSqlReadModel<CompanyReadModel, CompanyReadModelLocator>()
.RegisterServices( sr => sr.AddSingleton<IReadModelSqlGenerator>(new ReadModelSqlGenerator()));
}
public static IServiceCollection AddRepositories(this IServiceCollection services)
{
// Register locators
services.AddTransient<CompanyReadModelLocator>();
// Register repositories
services.AddScoped<ICompanyRepository, CompanyRepository>();
return services;
}
}