Esempio n. 1
0
        private static void RegisterConventions(StoreOptions options)
        {
            options.Schema.For<Organization>()
               .Duplicate(o => o.Slug);

            options.Schema.For<Campaign>()
                .ForeignKey<Organization>(d => d.OrganizationId);

            options.Schema.For<Donor>()
                .ForeignKey<Organization>(o => o.OrganizationId);

            options.Schema.For<Donation>()
                .ForeignKey<Organization>(d => d.OrganizationId)
                .ForeignKey<Campaign>(d => d.CampaignId)
                .ForeignKey<Donor>(d => d.DonorId);

            options.Schema.For<Event>()
                .ForeignKey<Organization>(e => e.OrganizationId)
                .Duplicate(e => e.Slug);

            options.Schema.For<User>()
                .ForeignKey<Organization>(u => u.OrganizationId)
                .Duplicate(u => u.EmailAddress);

            options.Schema.For<Volunteer>()
                .ForeignKey<Organization>(v => v.OrganizationId);
        }
Esempio n. 2
0
 public AdvancedOptions(IDocumentCleaner cleaner, StoreOptions options, ISerializer serializer, IDocumentSchema schema)
 {
     _serializer = serializer;
     _schema = schema;
     Options = options;
     Clean = cleaner;
 }
Esempio n. 3
0
        // 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;
        }
Esempio n. 4
0
        public static void Register(StoreOptions options)
        {
            RegisterConventions(options);

            options.Listeners.Add(new DocumentSessionListener
            {
                OnDocumentAddedForStorage = (id, document) =>
                {
                    var idoc = document as IDocument;
                    if (idoc != null)
                    {
                        Ensure.NotEqual(idoc.CreatedUtc, default(DateTime), $"CreatedUtc was not set on doc {id}");
                        Ensure.NotEqual(idoc.LastModifiedBy, default(Guid), $"LastModifiedBy was not set on doc {id}");
                        Ensure.NotEqual(idoc.LastModifiedUtc, default(DateTime), $"LastModifiedUtc was not set on doc {id}");
                        Ensure.NotEqual(idoc.LastModifiedBy, default(Guid), $"LastModifiedBy was not set on doc {id}");
                    }
                }
            });
        }
Esempio n. 5
0
 public static MartenConfigurationExpression AddMarten(this IServiceCollection services, StoreOptions options)
 {
     services.AddMarten(s => options);
     return(new MartenConfigurationExpression(services, options));
 }
Esempio n. 6
0
 internal void Alter(StoreOptions schema)
 {
     _alterations.Each(x => x(schema));
 }
 public void Configure(IServiceProvider services, StoreOptions options)
 {
     _configure(services, options);
 }
 public void Configure(IServiceProvider services, StoreOptions options)
 {
     options.InitialData.Add(_data);
 }
 internal MartenConfigurationExpression(IServiceCollection services, StoreOptions options)
 {
     _services = services;
     _options  = options;
 }
Esempio n. 10
0
 public PoliciesExpression(StoreOptions parent)
 {
     _parent = parent;
 }
Esempio n. 11
0
        /// <summary>
        /// Add Marten IDocumentStore, IDocumentSession, and IQuerySession service registrations
        /// to your application using the configured StoreOptions
        /// </summary>
        /// <param name="services"></param>
        /// <param name="options">The Marten configuration for this application</param>
        /// <returns></returns>
        public static MartenConfigurationExpression AddMarten(this IServiceCollection services, StoreOptions options)
        {
            services.AddSingleton <IDocumentStore>(s =>
            {
                var logger = s.GetService <ILogger <IDocumentStore> >() ?? new NullLogger <IDocumentStore>();
                options.Logger(new DefaultMartenLogger(logger));

                return(new DocumentStore(options));
            });

            // This can be overridden by the expression following
            services.AddSingleton <ISessionFactory, DefaultSessionFactory>();


            services.AddScoped(s => s.GetRequiredService <ISessionFactory>().QuerySession());
            services.AddScoped(s => s.GetRequiredService <ISessionFactory>().OpenSession());

            switch (options.Events.Daemon.Mode)
            {
            case DaemonMode.Disabled:
                // Nothing
                break;

            case DaemonMode.Solo:
                services.AddSingleton <INodeCoordinator, SoloCoordinator>();
                services.AddHostedService <AsyncProjectionHostedService>();
                break;

            case DaemonMode.HotCold:
                services.AddSingleton <INodeCoordinator, HotColdCoordinator>();
                services.AddHostedService <AsyncProjectionHostedService>();
                break;
            }

            return(new MartenConfigurationExpression(services, options));
        }
Esempio n. 12
0
 public GeneratedEventDocumentStorage(Marten.StoreOptions options) : base(options)
 {
     _options = options;
 }
Esempio n. 13
0
 public IFirstStoreImplementation1763841752(Marten.StoreOptions options) : base(options)
 {
     _options = options;
 }
Esempio n. 14
0
 public AdvancedOptions(IDocumentCleaner cleaner, StoreOptions options)
 {
     Options = options;
     Clean = cleaner;
 }
Esempio n. 15
0
 public AdvancedOptions(IDocumentCleaner cleaner, StoreOptions options)
 {
     Options = options;
     Clean   = cleaner;
 }
Esempio n. 16
0
 public QuerySession(IDocumentStore store, IDocumentSchema schema, ISerializer serializer,
                     IManagedConnection connection, IQueryParser parser, IIdentityMap identityMap, StoreOptions options)
 {
     DocumentStore = store;
     _schema       = schema;
     _serializer   = serializer;
     _connection   = connection;
     _parser       = parser;
     _identityMap  = identityMap;
 }
Esempio n. 17
0
            public void BuildAndStore(Assembly assembly, DocumentMapping mapping, StoreOptions options)
            {
                var provider = DocumentPersistenceBuilder.FromPreBuiltTypes <T>(assembly, mapping);

                options.Providers.Append(provider);
            }
        /// <summary>
        /// Add Marten IDocumentStore, IDocumentSession, and IQuerySession service registrations
        /// to your application using the configured StoreOptions
        /// </summary>
        /// <param name="services"></param>
        /// <param name="options">The Marten configuration for this application</param>
        /// <returns></returns>
        public static MartenConfigurationExpression AddMarten(this IServiceCollection services, StoreOptions options)
        {
            services.AddSingleton(options);
            services.AddSingleton <IDocumentStore, DocumentStore>();

            // This can be overridden by the expression following
            services.AddSingleton <ISessionFactory, DefaultSessionFactory>();


            services.AddScoped(s => s.GetRequiredService <ISessionFactory>().QuerySession());
            services.AddScoped(s => s.GetRequiredService <ISessionFactory>().OpenSession());

            return(new MartenConfigurationExpression(services, options));
        }
Esempio n. 19
0
 public MartenRegistry(StoreOptions options)
 {
     _options = options;
 }
Esempio n. 20
0
 public IOtherStoreImplementation1113575566(Marten.StoreOptions options) : base(options)
 {
     _options = options;
 }