コード例 #1
0
        public void can_create_storage_for_a_document_type_with_subclasses()
        {
            _schema.Alter(r =>
            {
                r.For <Squad>().AddSubclass <FootballTeam>().AddSubclass <BaseballTeam>();
            });

            _schema.StorageFor(typeof(Squad)).ShouldNotBeNull();
        }
コード例 #2
0
        /// <summary>
        /// Creates a new DocumentStore with the supplied StoreOptions
        /// </summary>
        /// <param name="options"></param>
        public DocumentStore(StoreOptions options)
        {
            _options           = options;
            _connectionFactory = options.ConnectionFactory();
            _runner            = new ManagedConnection(_connectionFactory, CommandRunnerMode.ReadOnly);

            _logger = options.Logger();

            var creation = options.AutoCreateSchemaObjects
                ? (IDocumentSchemaCreation) new DevelopmentSchemaCreation(_connectionFactory, _logger)
                : new ProductionSchemaCreation();

            Schema = new DocumentSchema(_options, _connectionFactory, creation);

            Schema.Alter(options.Schema);

            _serializer = options.Serializer();

            var cleaner = new DocumentCleaner(_connectionFactory, Schema);

            Advanced = new AdvancedOptions(cleaner, options);

            Diagnostics = new Diagnostics(Schema, new MartenQueryExecutor(_runner, Schema, _serializer, _parser, new NulloIdentityMap(_serializer)));

            EventStore = new EventStoreAdmin(_connectionFactory, _options, creation, _serializer);
        }
コード例 #3
0
        /// <summary>
        /// Creates a new DocumentStore with the supplied StoreOptions
        /// </summary>
        /// <param name="options"></param>
        public DocumentStore(StoreOptions options)
        {
            _options = options;
            _runner  = new CommandRunner(options.ConnectionFactory());

            var creation = options.AutoCreateSchemaObjects
                ? (IDocumentSchemaCreation) new DevelopmentSchemaCreation(_runner)
                : new ProductionSchemaCreation();

            Schema = new DocumentSchema(_options, _runner, creation);

            Schema.Alter(options.Schema);

            _serializer = options.Serializer();

            var cleaner = new DocumentCleaner(_runner, Schema);

            Advanced = new AdvancedOptions(cleaner, options);

            Diagnostics = new Diagnostics(Schema, new MartenQueryExecutor(_runner, Schema, _serializer, _parser, new NulloIdentityMap(_serializer)));


            if (options.RequestCounterThreshold.HasThreshold)
            {
                _runnerForSession = () => new RequestCounter(_runner, options.RequestCounterThreshold);
            }
            else
            {
                _runnerForSession = () => _runner;
            }
        }
コード例 #4
0
        public void can_override_with_MartenRegistry()
        {
            var registry = new MartenRegistry();

            registry.For <Organization>().Searchable(x => x.Time2, pgType: "timestamp");

            var schema = new DocumentSchema(new StoreOptions(), null, null);

            schema.Alter(registry);

            schema.MappingFor(typeof(Organization)).DuplicatedFields.Single(x => x.MemberName == "Time2")
            .PgType.ShouldBe("timestamp");
        }
コード例 #5
0
        public MartenRegistryTests()
        {
            theSchema = Container.For <DevelopmentModeRegistry>().GetInstance <DocumentSchema>();

            theSchema.Alter <TestRegistry>();
        }