示例#1
0
        public void OwnedCollectionRemove()
        {
            using (var uow = new TestDbContext(_connection, new GraphdiffAggregateUpdateStrategy()))
            {
                var company1 = uow.Companies
                               .Include(p => p.Contacts.Select(m => m.Infos))
                               .Single(p => p.Id == 2);

                var contact = company1.Contacts.Single();
                company1.Contacts.Remove(contact);

                var repo = new CompanyRepository(uow);
                repo.AlterarAgregacao(company1, cfg => cfg.HasMany(c => c.Contacts));

                uow.Commit();
            }

            using (var uow = new TestDbContext(_connection))
            {
                var company = uow.Companies.Include(p => p.Contacts.Select(m => m.Infos)).Single(p => p.Id == 2);

                Assert.IsTrue(company.Contacts.Count == 0);
            }
        }
示例#2
0
        public void OwnedCollectionRemove()
        {
            using (var uow = new TestDbContext(_connection, new GraphdiffAggregateUpdateStrategy()))
            {
                var company1 = uow.Companies
                    .Include(p => p.Contacts.Select(m => m.Infos))
                    .Single(p => p.Id == 2);

                var contact = company1.Contacts.Single();
                company1.Contacts.Remove(contact);

                var repo = new CompanyRepository(uow);
                repo.AlterarAgregacao(company1, cfg => cfg.HasMany(c => c.Contacts));

                uow.Commit();
            }

            using (var uow = new TestDbContext(_connection))
            {
                var company = uow.Companies.Include(p => p.Contacts.Select(m => m.Infos)).Single(p => p.Id == 2);

                Assert.IsTrue(company.Contacts.Count == 0);

            }
        }