public void should_get_foreign_key_from_attribute()
 {
     var schema = new DocumentSchema(new StoreOptions(), null, null);
     schema.MappingFor(typeof (Issue))
         .As<DocumentMapping>()
         .ForeignKeys
         .ShouldContain(x => x.ColumnName == "user_id");
 }
 public void cannot_use_a_doc_type_with_no_id()
 {
     Exception<InvalidDocumentException>.ShouldBeThrownBy(() =>
     {
         var schema = new DocumentSchema(new StoreOptions(), null, null);
         schema.MappingFor(typeof(BadDoc)).ShouldBeNull();
     });
     
 }
        public void can_override_with_MartenRegistry()
        {
            var storeOptions = new StoreOptions();
            storeOptions.Schema.For<Organization>().Duplicate(x => x.Time2, pgType: "timestamp");

            var schema = new DocumentSchema(storeOptions, null, new NulloMartenLogger());

            schema.MappingFor(typeof(Organization)).As<DocumentMapping>().DuplicatedFields.Single(x => x.MemberName == "Time2")
                .PgType.ShouldBe("timestamp");
        }
        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");
        }
        public void should_get_foreign_key_from_registry()
        {
            var storeOptions = new StoreOptions();
            storeOptions.Schema.For<Issue>().ForeignKey<User>(i => i.OtherUserId);

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

            schema.MappingFor(typeof(Issue))
                .As<DocumentMapping>()
                .ForeignKeys
                .ShouldContain(x => x.ColumnName == "other_user_id");
        }
        public when_deriving_the_table_definition_from_the_database_schema_Tests()
        {
            ConnectionSource.CleanBasicDocuments();
            _schema = _container.GetInstance<DocumentSchema>();

            theMapping = _schema.MappingFor(typeof(User));
            theMapping.DuplicateField("UserName");


            _storage = _schema.StorageFor(typeof(User));

            theDerivedTable = _schema.TableSchema(theMapping.TableName);
        }
Пример #7
0
        public void DeleteDocumentsFor(Type documentType)
        {
            var mapping = _schema.MappingFor(documentType);

            mapping.DeleteAllDocuments(_factory);
        }
Пример #8
0
        public TableDefinition TableSchema(Type documentType)
        {
            var mapping = _schema.MappingFor(documentType);

            return(TableSchema(mapping));
        }