예제 #1
0
 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
 /// <summary>
 /// Create a new Contact object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 public static Contact CreateContact(global::System.Int32 id)
 {
     Contact contact = new Contact();
     contact.Id = id;
     return contact;
 }
예제 #3
0
 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();
     }
 }
예제 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ContactSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToContactSet(Contact contact)
 {
     base.AddObject("ContactSet", contact);
 }