/// <summary> /// Inits Event Store /// </summary> public Exercise09Projections() { databaseConnection = PostgresDbConnectionProvider.GetFreshDbConnection(); var databaseProvider = new PostgresqlDatabaseProvider(databaseConnection) { SchemaName = typeof(Exercise09Projections).Name }; var migrationsAssembly = typeof(Exercise09Projections).Assembly; var migrator = new SimpleMigrator(migrationsAssembly, databaseProvider); migrator.Load(); migrator.MigrateToLatest(); // Create Event Store eventStore = new EventStore(databaseConnection); eventStore.AddProjection(new UserDashboardProjection(databaseConnection)); // Initialize Event Store eventStore.Init(); userRepository = new Repository <User>(eventStore); orderRepository = new Repository <Order>(eventStore); }
/// <summary> /// Inits Event Store /// </summary> public Exercise08Snapshots() { databaseConnection = PostgresDbConnectionProvider.GetFreshDbConnection(); var databaseProvider = new PostgresqlDatabaseProvider(databaseConnection) { SchemaName = typeof(Exercise08Snapshots).Name }; var migrationsAssembly = typeof(Exercise08Snapshots).Assembly; var migrator = new SimpleMigrator(migrationsAssembly, databaseProvider); migrator.Load(); migrator.MigrateToLatest(); // Create Event Store eventStore = new EventStore(databaseConnection); var userSnapshot = new SnapshotToTable <User>( databaseConnection, @"TODO write upsert here"); eventStore.AddSnapshot(userSnapshot); // Initialize Event Store eventStore.Init(); repository = new Repository <User>(eventStore); }
/// <summary> /// Inits Event Store /// </summary> public Exercise08Snapshots() { databaseConnection = PostgresDbConnectionProvider.GetFreshDbConnection(); var databaseProvider = new PostgresqlDatabaseProvider(databaseConnection) { SchemaName = typeof(Exercise08Snapshots).Name }; var migrationsAssembly = typeof(Exercise08Snapshots).Assembly; var migrator = new SimpleMigrator(migrationsAssembly, databaseProvider); migrator.Load(); migrator.MigrateToLatest(); // Create Event Store eventStore = new EventStore(databaseConnection); var userSnapshot = new SnapshotToTable <User>( databaseConnection, @"INSERT INTO users (id, name, version) VALUES (@Id, @Name, @Version) ON CONFLICT (id) DO UPDATE SET name = @Name, version = @Version"); eventStore.AddSnapshot(userSnapshot); // Initialize Event Store eventStore.Init(); repository = new Repository <User>(eventStore); }
public ICollection <Crumb> GetCrumbs(string query) { using var connection = PostgresDbConnectionProvider.GetDbConnection(); var events = connection.Query <Crumb>(query).ToList(); return(events); }
/// <summary> /// Inits Event Store /// </summary> public Exercise05StreamAggregation() { databaseConnection = PostgresDbConnectionProvider.GetFreshDbConnection(); // Create Event Store eventStore = new EventStore(databaseConnection); // Initialize Event Store eventStore.Init(); }
/// <summary> /// Inits Event Store /// </summary> public Exercise06TimeTravelling() { databaseConnection = PostgresDbConnectionProvider.GetFreshDbConnection(); // Create Event Store eventStore = new EventStore(databaseConnection); // Initialize Event Store eventStore.Init(); }
/// <summary> /// Inits Event Store /// </summary> public Exercise01CreateStreamsTable() { databaseConnection = PostgresDbConnectionProvider.GetFreshDbConnection(); schemaProvider = new PostgresSchemaProvider(databaseConnection); // Create Event Store var eventStore = new EventStore(databaseConnection); // Initialize Event Store eventStore.Init(); }
/// <summary> /// Inits Event Store /// </summary> public Exercise03CreateAppendEventFunction() { databaseConnection = PostgresDbConnectionProvider.GetFreshDbConnection(); schemaProvider = new PostgresSchemaProvider(databaseConnection); // Create Event Store eventStore = new EventStore(databaseConnection); // Initialize Event Store eventStore.Init(); }
/// <summary> /// Inits Event Store /// </summary> public Exercise03OptimisticConcurrency() { databaseConnection = PostgresDbConnectionProvider.GetFreshDbConnection(); schemaProvider = new PostgresSchemaProvider(databaseConnection); // Create Event Store eventStore = new EventStore(databaseConnection); // Initialize Event Store eventStore.Init(); }
private static IServiceProvider CreateServices() { return(new ServiceCollection() .AddFluentMigratorCore() .ConfigureRunner(rb => rb .AddPostgres10_0() .WithGlobalConnectionString(PostgresDbConnectionProvider.GetDbConnectionString()) .ScanIn(typeof(AddLogTable).Assembly).For.Migrations()) .AddLogging(lb => lb.AddFluentMigratorConsole()) .BuildServiceProvider(false)); }
/// <summary> /// Inits Event Store /// </summary> public Exercise07AggregateAndRepository() { databaseConnection = PostgresDbConnectionProvider.GetFreshDbConnection(); // Create Event Store eventStore = new EventStore(databaseConnection); // Initialize Event Store eventStore.Init(); repository = new Repository <User>(eventStore); }