Esempio n. 1
0
        public void apply_updates_via_the_actual_document()
        {
            var stringDoc1 = new StringDoc {Id = "Foo"};
            var stringDoc2 = new StringDoc {Id = "Bar"};
            var user1 = new User();
            var user2 = new User();
            var int1 = new IntDoc {Id = 1};
            var int2 = new IntDoc {Id = 2};
            var long1 = new LongDoc {Id = 3};
            var long2 = new LongDoc {Id = 4};

            var uow1 = theContainer.GetInstance<UnitOfWork>();
            uow1.Store(user1, user2);
            uow1.Store(stringDoc1, stringDoc2);
            uow1.Store(int1, int2);
            uow1.Store(long1, long2);
            var batch1 = theContainer.GetInstance<UpdateBatch>();
            uow1.ApplyChanges(batch1);


            var uow2 = theContainer.GetInstance<UnitOfWork>();
            uow2.Delete(stringDoc2);
            uow2.Delete(user2);
            uow2.Delete(int2);
            uow2.Delete(long2);
            var batch2 = theContainer.GetInstance<UpdateBatch>();
            uow2.ApplyChanges(batch2);

            theSession.Query<StringDoc>().Single().Id.ShouldBe(stringDoc1.Id);
            theSession.Query<User>().Single().Id.ShouldBe(user1.Id);
            theSession.Query<IntDoc>().Single().Id.ShouldBe(int1.Id);
            theSession.Query<LongDoc>().Single().Id.ShouldBe(long1.Id);
        }
Esempio n. 2
0
        public void apply_updates_via_the_actual_document()
        {
            var stringDoc1 = new StringDoc {
                Id = "Foo"
            };
            var stringDoc2 = new StringDoc {
                Id = "Bar"
            };
            var user1 = new User();
            var user2 = new User();
            var int1  = new IntDoc {
                Id = 1
            };
            var int2 = new IntDoc {
                Id = 2
            };
            var long1 = new LongDoc {
                Id = 3
            };
            var long2 = new LongDoc {
                Id = 4
            };

            var uow1 = theStore.Advanced.CreateUnitOfWork();

            uow1.StoreUpdates(user1, user2);
            uow1.StoreUpdates(stringDoc1, stringDoc2);
            uow1.StoreUpdates(int1, int2);
            uow1.StoreUpdates(long1, long2);



            var batch1 = theStore.Advanced.CreateUpdateBatch();

            uow1.ApplyChanges(batch1);

            batch1.Connection.Dispose();


            var uow2 = theStore.Advanced.CreateUnitOfWork();

            uow2.DeleteEntity(stringDoc2);
            uow2.DeleteEntity(user2);
            uow2.DeleteEntity(int2);
            uow2.DeleteEntity(long2);
            var batch2 = theStore.Advanced.CreateUpdateBatch();

            uow2.ApplyChanges(batch2);

            batch2.Connection.Dispose();

            theSession.Query <StringDoc>().Single().Id.ShouldBe(stringDoc1.Id);
            theSession.Query <User>().Single().Id.ShouldBe(user1.Id);
            theSession.Query <IntDoc>().Single().Id.ShouldBe(int1.Id);
            theSession.Query <LongDoc>().Single().Id.ShouldBe(long1.Id);
        }
Esempio n. 3
0
        public void apply_updates_via_the_id()
        {
            var stringDoc1 = new StringDoc {
                Id = "Foo"
            };
            var stringDoc2 = new StringDoc {
                Id = "Bar"
            };
            var user1 = new User();
            var user2 = new User();
            var int1  = new IntDoc {
                Id = 1
            };
            var int2 = new IntDoc {
                Id = 2
            };
            var long1 = new LongDoc {
                Id = 3
            };
            var long2 = new LongDoc {
                Id = 4
            };

            var uow1 = theContainer.GetInstance <UnitOfWork>();

            uow1.Store(user1, user2);
            uow1.Store(stringDoc1, stringDoc2);
            uow1.Store(int1, int2);
            uow1.Store(long1, long2);
            var batch1 = theContainer.GetInstance <UpdateBatch>();

            uow1.ApplyChanges(batch1);

            batch1.Connection.Dispose();

            var uow2 = theContainer.GetInstance <UnitOfWork>();

            uow2.Delete <StringDoc>(stringDoc2.Id);
            uow2.Delete <User>(user2.Id);
            uow2.Delete <IntDoc>(int2.Id);
            uow2.Delete <LongDoc>(long2.Id);
            var batch2 = theContainer.GetInstance <UpdateBatch>();

            uow2.ApplyChanges(batch2);

            batch2.Connection.Dispose();

            theSession.Query <StringDoc>().Single().Id.ShouldBe(stringDoc1.Id);
            theSession.Query <User>().Single().Id.ShouldBe(user1.Id);
            theSession.Query <IntDoc>().Single().Id.ShouldBe(int1.Id);
            theSession.Query <LongDoc>().Single().Id.ShouldBe(long1.Id);
        }
        public void auto_assign_id_for_0_id()
        {
            var doc = new IntDoc {Id = 0};

            theSession.Store(doc);

            doc.Id.ShouldBeGreaterThan(0);

            var doc2 = new IntDoc {Id = 0};
            theSession.Store(doc2);

            doc2.Id.ShouldNotBe(0);

            doc2.Id.ShouldNotBe(doc.Id);
        }
        public void persist_and_load()
        {
            var IntDoc = new IntDoc { Id = 456 };

            theSession.Store(IntDoc);
            theSession.SaveChanges();

            using (var session = theContainer.GetInstance<IDocumentSession>())
            {
                session.Load<IntDoc>(456)
                    .ShouldNotBeNull();

                session.Load<IntDoc>(222)
                    .ShouldBeNull();
            }
        }
        public void persist_and_load()
        {
            var IntDoc = new IntDoc {
                Id = 456
            };

            theSession.Store(IntDoc);
            theSession.SaveChanges();

            using (var session = theContainer.GetInstance <IDocumentSession>())
            {
                session.Load <IntDoc>(456)
                .ShouldNotBeNull();

                session.Load <IntDoc>(222)
                .ShouldBeNull();
            }
        }
        public void persist_and_load()
        {
            var IntDoc = new IntDoc {
                Id = 456
            };

            theSession.Store(IntDoc);
            theSession.SaveChanges();

            using (var session = theStore.OpenSession())
            {
                session.Load <IntDoc>(456)
                .ShouldNotBeNull();

                session.Load <IntDoc>(222)
                .ShouldBeNull();
            }
        }
        public void persist_and_delete()
        {
            var IntDoc = new IntDoc { Id = 567 };

            theSession.Store(IntDoc);
            theSession.SaveChanges();

            using (var session = theContainer.GetInstance<IDocumentSession>())
            {
                session.Delete<IntDoc>(IntDoc.Id);
                session.SaveChanges();
            }

            using (var session = theContainer.GetInstance<IDocumentSession>())
            {
                session.Load<IntDoc>(IntDoc.Id)
                    .ShouldBeNull();
            }
        }
Esempio n. 9
0
        public void auto_assign_id_for_0_id()
        {
            var doc = new IntDoc {
                Id = 0
            };

            theSession.Store(doc);

            doc.Id.ShouldBeGreaterThan(0);

            var doc2 = new IntDoc {
                Id = 0
            };

            theSession.Store(doc2);

            doc2.Id.ShouldNotBe(0);

            doc2.Id.ShouldNotBe(doc.Id);
        }
        public void persist_and_delete()
        {
            var IntDoc = new IntDoc {
                Id = 567
            };

            theSession.Store(IntDoc);
            theSession.SaveChanges();

            using (var session = theContainer.GetInstance <IDocumentSession>())
            {
                session.Delete <IntDoc>(IntDoc.Id);
                session.SaveChanges();
            }

            using (var session = theContainer.GetInstance <IDocumentSession>())
            {
                session.Load <IntDoc>(IntDoc.Id)
                .ShouldBeNull();
            }
        }
        public void persist_and_delete()
        {
            var IntDoc = new IntDoc {
                Id = 567
            };

            theSession.Store(IntDoc);
            theSession.SaveChanges();

            using (var session = theStore.OpenSession())
            {
                session.Delete <IntDoc>(IntDoc.Id);
                session.SaveChanges();
            }

            using (var session = theStore.OpenSession())
            {
                session.Load <IntDoc>(IntDoc.Id)
                .ShouldBeNull();
            }
        }
Esempio n. 12
0
        public void can_delete_by_query_with_complex_where_clauses()
        {
            var targets = Target.GenerateRandomData(50).ToArray();

            for (var i = 0; i < 15; i++)
            {
                targets[i].Double = 578;
            }

            theStore.BulkInsert(targets);

            var current = new IntDoc {
                Id = 5
            };

            theSession.DeleteWhere <Target>(x => x.Double == 578 && x.Number == current.Id);

            theSession.SaveChanges();

            theSession.Query <Target>().Where(x => x.Double == 578 && x.Number == current.Id).Count()
            .ShouldBe(0);
        }