Esempio n. 1
0
        public void can_create_storage_for_a_document_type_with_subclasses()
        {
            StoreOptions(_ =>
            {
                _.Schema.For <Squad>().AddSubClass <FootballTeam>().AddSubClass <BaseballTeam>();
            });

            SpecificationExtensions.ShouldNotBeNull(theStore.Tenancy.Default.StorageFor(typeof(Squad)));
        }
        public void do_not_lose_data_if_only_change_is_searchable_field_for_AutoCreateMode_is_CreateOrUpdate()
        {
            var user1 = new User {
                FirstName = "Jeremy"
            };
            var user2 = new User {
                FirstName = "Max"
            };
            var user3 = new User {
                FirstName = "Declan"
            };

            theStore.BulkInsert(new User[] { user1, user2, user3 });

            using (var store2 = DocumentStore.For(_ =>
            {
                _.AutoCreateSchemaObjects = AutoCreate.CreateOrUpdate;
                _.Connection(ConnectionSource.ConnectionString);
                _.Schema.For <User>().Duplicate(x => x.FirstName);
            }))
            {
                using (var session = store2.QuerySession())
                {
                    session.Query <User>().Count().ShouldBe(3);

                    var list = new List <string>();

                    using (
                        var reader =
                            session.Connection.CreateCommand()
                            .WithText("select first_name from mt_doc_user")
                            .ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            list.Add(reader.GetString(0));
                        }
                    }

                    list.OrderBy(x => x).ShouldHaveTheSameElementsAs("Declan", "Jeremy", "Max");

                    SpecificationExtensions.ShouldNotBeNull(session.Query <User>().Where(x => x.FirstName == "Jeremy").Single());
                }
            }
        }
Esempio n. 3
0
        public void builds_schema_objects_on_the_fly_as_needed()
        {
            SpecificationExtensions.ShouldNotBeNull(theStore.Tenancy.Default.StorageFor(typeof(User)));
            SpecificationExtensions.ShouldNotBeNull(theStore.Tenancy.Default.StorageFor(typeof(Issue)));
            SpecificationExtensions.ShouldNotBeNull(theStore.Tenancy.Default.StorageFor(typeof(Company)));

            var tables = theStore.Tenancy.Default.DbObjects.SchemaTables();

            tables.ShouldContain("other.mt_doc_user");
            tables.ShouldContain("other.mt_doc_issue");
            tables.ShouldContain("other.mt_doc_company");

            var functions = theStore.Tenancy.Default.DbObjects.Functions();

            functions.ShouldContain("other.mt_upsert_user");
            functions.ShouldContain("other.mt_upsert_issue");
            functions.ShouldContain("other.mt_upsert_company");
        }
Esempio n. 4
0
        public void can_create_a_new_storage_for_a_document_type_without_subclasses()
        {
            var storage = theStore.Tenancy.Default.StorageFor(typeof(User));

            SpecificationExtensions.ShouldNotBeNull(storage);
        }