/// <summary> /// Customize the store configuration for one off tests. /// The return value is the database schema /// </summary> /// <param name="configure"></param> /// <returns></returns> protected string StoreOptions(Action <StoreOptions> configure) { overrideSession = true; if (session != null) { session.Dispose(); Disposables.Remove(session); session = null; } var options = new StoreOptions(); options.Connection(ConnectionSource.ConnectionString); // Can be overridden options.AutoCreateSchemaObjects = AutoCreate.All; options.NameDataLength = 100; options.DatabaseSchemaName = "special"; configure(options); store = new DocumentStore(options); Disposables.Add(store); store.Advanced.Clean.CompletelyRemoveAll(); return(options.DatabaseSchemaName); }
public virtual StoreOptions Create() { var options = new StoreOptions(); string schemaName = "public"; string connectionString = eventStoreConnectionStringProvider.Get(); options.Connection(connectionString); options.AutoCreateSchemaObjects = AutoCreate.All; options.Events.DatabaseSchemaName = schemaName; options.DatabaseSchemaName = schemaName; // options.Events.InlineProjections.AggregateStreamsWith<OrderAggregate>(); options.Events.InlineProjections.Add(new OrderViewProjection()); options.Events.AddEventType(typeof(OrderCreated)); options.Events.AddEventType(typeof(OrderLineAdded)); options.Events.AddEventType(typeof(OrderLineRemoved)); options.Events.AddEventType(typeof(OrderItemQuantityAdded)); options.Events.AddEventType(typeof(OrderItemQuantitySubtracted)); // options.Events.InlineProjections.AggregateStreamsWith<WarehouseAggregate>(); options.Events.InlineProjections.Add(new WarehouseViewProjection()); options.Events.AddEventType(typeof(WarehouseCreated)); options.Events.AddEventType(typeof(WarehouseItemAdded)); options.Events.AddEventType(typeof(WarehouseItemQuantitySubstracted)); return(options); }
/// <summary> /// Customize the store configuration for one off tests. /// The return value is the database schema /// </summary> /// <param name="configure"></param> /// <returns></returns> protected string StoreOptions(Action <StoreOptions> configure) { if (_session != null) { _session.Dispose(); Disposables.Remove(_session); _session = null; } var options = new StoreOptions(); options.Connection(ConnectionSource.ConnectionString); // Can be overridden options.AutoCreateSchemaObjects = AutoCreate.All; options.NameDataLength = 100; options.DatabaseSchemaName = GetType().Name.Sanitize(); configure(options); _store = new DocumentStore(options); Disposables.Add(_store); _store.Advanced.Clean.CompletelyRemoveAll(); return(options.DatabaseSchemaName); }
private static void SetStoreOptions(StoreOptions options, Config config, Action <StoreOptions>?configureOptions = null) { options.Connection(config.ConnectionString); options.AutoCreateSchemaObjects = AutoCreate.CreateOrUpdate; var schemaName = Environment.GetEnvironmentVariable("SchemaName"); options.Events.DatabaseSchemaName = schemaName ?? config.WriteModelSchema; options.DatabaseSchemaName = schemaName ?? config.ReadModelSchema; var serializer = new JsonNetSerializer { EnumStorage = EnumStorage.AsString }; serializer.Customize(s => { s.ContractResolver = new NonDefaultConstructorMartenJsonNetContractResolver( Casing.Default, CollectionStorage.Default, NonPublicMembersStorage.NonPublicSetters ); }); options.Serializer(serializer); configureOptions?.Invoke(options); }
protected DocumentStore StoreOptions(Action <StoreOptions> configure, bool cleanAll = true) { var options = new StoreOptions(); options.Connection(ConnectionSource.ConnectionString); // Can be overridden options.AutoCreateSchemaObjects = AutoCreate.All; options.NameDataLength = 100; options.DatabaseSchemaName = _schemaName; configure(options); if (cleanAll) { using (var conn = new NpgsqlConnection(ConnectionSource.ConnectionString)) { conn.Open(); conn.CreateCommand($"drop schema if exists {_schemaName} cascade") .ExecuteNonQuery(); } } _store = new DocumentStore(options); _disposables.Add(_store); return(_store); }
public PostgresEventStore(IServiceProvider serviceProvider, string connectionString, string databaseSchemaName, bool cleanAll = false) { _aggregateRepository = new AggregateRepository(this); _projectionRepository = new ProjectionRepository(serviceProvider); var options = new StoreOptions(); options.Connection(connectionString); options.Projections.Add(new Projection(_projectionRepository)); // Serialize enums as strings var serializer = new Marten.Services.JsonNetSerializer(); serializer.EnumStorage = Weasel.Core.EnumStorage.AsString; options.Serializer(serializer); // Can be overridden options.AutoCreateSchemaObjects = Weasel.Postgresql.AutoCreate.All; options.DatabaseSchemaName = databaseSchemaName; _store = new DocumentStore(options); if (cleanAll) { _store.Advanced.Clean.CompletelyRemoveAll(); } _commandLog = new PostgresCommandLog(_store); _sequences = new PostgresSequenceStore(connectionString, databaseSchemaName); }
public Provider(IConfiguration configuration) { var options = new StoreOptions(); options.Connection(configuration["ConnectionString"]); _store = new DocumentStore(options); }
private StoreOptions BuildStoreOptions() { var options = new StoreOptions(); options.Connection("host=localhost;database=bolton;password=bolton;username=bolton"); options.AutoCreateSchemaObjects = Weasel.Postgresql.AutoCreate.All; return(options); }
private static void SetStoreOptions(StoreOptions options, MartenOptions config, Action <StoreOptions> configureOptions = null) { options.Connection(config.ConnectionString); options.AutoCreateSchemaObjects = AutoCreate.All; options.Events.DatabaseSchemaName = config.WriteModelSchema; options.DatabaseSchemaName = config.ReadModelSchema; configureOptions?.Invoke(options); }
private StoreOptions BuildStoreOptions() { var connectionString = Configuration.GetConnectionString("postgres"); // Or lastly, build a StoreOptions object yourself var options = new StoreOptions(); options.Connection(connectionString); return(options); }
private void ConfigureMarten(StoreOptions options, string connectionString) { options.Connection(connectionString); var jsonNetSerializer = new JsonNetSerializer(); jsonNetSerializer.Customize(serializer => serializer.UseCustomConverters()); options.Serializer(jsonNetSerializer); }
private static void SetStoreOptions(StoreOptions options, MartenConfig config, Action <StoreOptions> configureOptions = null) { options.Connection(config.ConnectionString); options.AutoCreateSchemaObjects = AutoCreate.CreateOrUpdate; options.Events.DatabaseSchemaName = config.WriteModelSchema; options.DatabaseSchemaName = config.ReadModelSchema; options.UseDefaultSerialization(nonPublicMembersStorage: NonPublicMembersStorage.NonPublicSetters, enumStorage: EnumStorage.AsString); configureOptions?.Invoke(options); }
public static IServiceCollection AddMartenDB(this IServiceCollection services, IConfiguration configuration) { var connectionString = GetConnectionString(configuration); var options = new StoreOptions(); options.Connection(connectionString); options.Events.InlineProjections.AggregateStreamsWith <Payment>(); services.AddMarten(options); return(services); }
public MartenSubscriptionSettings() { _store = new Lazy <IDocumentStore>(() => new DocumentStore(StoreOptions)); var connectionString = Environment.GetEnvironmentVariable("marten_subscription_database"); if (connectionString != null) { StoreOptions.Connection(connectionString); } }
private static void SetStoreOptions(StoreOptions options, IConfiguration configuration, Action <StoreOptions> configureOptions = null) { var config = configuration.GetSection(DefaultConfigKey).Get <MartenConfig>(); options.Connection(config.ConnectionString); options.AutoCreateSchemaObjects = AutoCreate.All; options.Events.DatabaseSchemaName = config.WriteModelSchema; options.DatabaseSchemaName = config.ReadModelSchema; configureOptions?.Invoke(options); }
public void add_marten_by_store_options() { using var container = Container.For(x => { var options = new StoreOptions(); options.Connection(ConnectionSource.ConnectionString); x.AddMarten(options); }); ShouldHaveAllTheExpectedRegistrations(container); }
private static void SetStoreOptions(StoreOptions options, IConfiguration config) { var martenConfig = config.GetSection("EventStore"); var connectionString = martenConfig.GetSection("ConnectionString").Value; var schemaName = martenConfig.GetSection("Schema").Value; options.Connection(connectionString); options.AutoCreateSchemaObjects = AutoCreate.All; options.Events.DatabaseSchemaName = schemaName; options.DatabaseSchemaName = schemaName; }
public IDocumentStore InitStore() { var options = new StoreOptions(); options.Connection(ConnectionSource.ConnectionString); options.Events.AddEventTypes(new[] { typeof(UserCreated) }); options.Events.InlineProjections.Add(new UserViewProjection()); options.RegisterDocumentType <User>(); return(DocumentStore.For(ConnectionSource.ConnectionString)); }
public void add_the_tenant_id_column_when_it_is_conjoined_tenancy() { var options = new StoreOptions(); options.Connection(ConnectionSource.ConnectionString).MultiTenanted(); var mapping = new DocumentMapping(typeof(User), options); var table = new DocumentTable(mapping); table.Any(x => x is TenantIdColumn).ShouldBeTrue(); }
public static IServiceCollection AddMartenDB(this IServiceCollection services, IConfiguration configuration) { var connectionString = GetConnectionString(configuration); var options = new StoreOptions(); options.Connection(connectionString); options.Events.UseAggregatorLookup(AggregationLookupStrategy.UsePrivateApply); //options.Events.InlineProjections.AggregateStreamsWith<>(); services.AddMarten(options); return(services); }
// build out the StoreOptions that you need for your application private static StoreOptions configureStoreOptions() { var options = new StoreOptions(); options.Schema.For <User>(); options.Schema.For <Issue>(); options.Schema.For <Target>(); options.Connection(ConnectionSource.ConnectionString); return(options); }
public void no_tenant_id_if_single_tenant() { var options = new StoreOptions(); options.Connection(ConnectionSource.ConnectionString); var mapping = new DocumentMapping(typeof(User), options); var func = new UpsertFunction(mapping); func.Arguments.Any(x => x is TenantIdArgument) .ShouldBeFalse(); }
public MartenSubscriptionSettings() { StoreOptions.Schema.For <ServiceCapabilities>().Identity(x => x.ServiceName); _store = new Lazy <IDocumentStore>(() => new DocumentStore(StoreOptions)); var connectionString = Environment.GetEnvironmentVariable("marten_subscription_database"); if (connectionString != null) { StoreOptions.Connection(connectionString); } }
private static void SetStoreOptions(StoreOptions options, Config config, Action <StoreOptions> configureOptions = null) { options.Connection(config.ConnectionString); options.AutoCreateSchemaObjects = AutoCreate.CreateOrUpdate; options.Events.DatabaseSchemaName = config.WriteModelSchema; options.DatabaseSchemaName = config.ReadModelSchema; options.UseDefaultSerialization(nonPublicMembersStorage: NonPublicMembersStorage.NonPublicSetters, enumStorage: EnumStorage.AsString); options.PLV8Enabled = false; options.Events.UseAggregatorLookup(AggregationLookupStrategy.UsePublicAndPrivateApply); configureOptions?.Invoke(options); }
private static StoreOptions ConfigureOptions(string connectionString, string schemaName) { var options = new StoreOptions(); options.AutoCreateSchemaObjects = AutoCreate.All; options.DatabaseSchemaName = schemaName; options.Connection(connectionString); options.Schema.For <User>().Index(x => x.Id); options.Schema.For <Page>().Identity(x => x.Id); options.Schema.For <Page>().Index(x => x.Id); options.Schema.For <PageVersion>().Index(x => x.Id); return(options); }
public void tenant_id_argument_when_multi_tenanted() { var options = new StoreOptions(); options.Connection(ConnectionSource.ConnectionString) .MultiTenanted(); var mapping = new DocumentMapping(typeof(User), options); var func = new UpsertFunction(mapping); func.Arguments.Any(x => x is TenantIdArgument) .ShouldBeTrue(); }
private static void Configure(string connectionString, StoreOptions opts) { opts.Connection(connectionString); opts.AutoCreateSchemaObjects = AutoCreate.CreateOrUpdate; opts.Schema.For <Dominio.Entidades.ContaCorrente>() .Identity(x => x.IdentificadorConta); opts.Schema.For <Dominio.Entidades.Lancamento>() .Identity(x => x.Id); opts.Schema.For <Dominio.Entidades.Cliente>() .Identity(x => x.IdentificadorCliente); }
public void ensure_patch_system_transform_functions_and_feature_schemas_are_added_only_once() { var options = new StoreOptions(); options.Connection(ConnectionSource.ConnectionString); var store1 = new DocumentStore(options); // pass with the same options and check it does not throw ArgumentException // "An item with the same key has already been added. Key: <transform function name/feature schema name>" Should.NotThrow(() => { var store2 = new DocumentStore(options); }); }
public new static IDocumentStore For(Action<StoreOptions> configure) { var options = new StoreOptions(); options.Connection(ConnectionSource.ConnectionString); options.Serializer<TestsSerializer>(); configure(options); var store = new TestingDocumentStore(options); store.Advanced.Clean.CompletelyRemoveAll(); return store; }
public void add_marten_by_store_options_with_custom_logger() { using var container = Container.For(x => { x.AddMarten(provider => { var options = new StoreOptions(); options.Connection(ConnectionSource.ConnectionString); options.Logger(new TestOutputMartenLogger(null)); return(options); }); }); var store = container.GetRequiredService <IDocumentStore>(); store.Options.Logger().ShouldBeOfType <TestOutputMartenLogger>(); }
public async Task can_write_both_files() { var options = new StoreOptions(); options.Connection(ConnectionSource.ConnectionString); options.Schema.For <User>(); options.Schema.For <Target>(); var input = new PatchInput() { HostBuilder = new HostBuilder().ConfigureServices(x => x.AddMarten(options)), FileName = Path.GetTempPath().AppendPath("dump1.sql"), }; await new PatchCommand().Execute(input); }
public new static IDocumentStore For(Action<StoreOptions> configure) { var options = new StoreOptions(); options.Connection(ConnectionSource.ConnectionString); lock (_locker) { //options.DatabaseSchemaName = "Test_" + SchemaCount++; } configure(options); var store = new TestingDocumentStore(options); store.Advanced.Clean.CompletelyRemoveAll(); return store; }