コード例 #1
0
ファイル: RelationshipTests.cs プロジェクト: jenrom/Spikes
 public void ContactHasOneOrZeroAddresses_AddressHasOneContact_WithEF()
 {
     using (new TransactionScope())
     {
         var entities = new Entities();
         var contact = new Contact{Name = "Test"};
         contact.Address = new Address {Street = "Lipowa"};
         entities.AddToContactSet(contact);
         entities.SaveChanges();
         List<Contact> contacts = entities.ContactSet.Where(x=>x.Name == "Test").ToList();
         entities.DeleteObject(contacts[0].Address);
         contacts[0].Address = null;
         entities.SaveChanges();
     }
 }
コード例 #2
0
ファイル: RelationshipTests.cs プロジェクト: jenrom/Spikes
 public void WhenRemovingContactShouldAlsoRemoveReferencedAddress_withEF()
 {
     using (new TransactionScope())
     {
         var contact = new Contact {Name = "Test", Address = new Address {Street = "Lipowa"}};
         var entities = new Entities();
         entities.AddToContactSet(contact);
         entities.SaveChanges();
         entities.DeleteObject(contact);
         entities.SaveChanges();
     }
 }