Ejemplo n.º 1
0
        private void Child_Update(CompanyContact companyContact, CompanyContacts entityContact)
        {
            using (ObjectContextManager <RolodexEntities> manager = ObjectContextManager <RolodexEF.RolodexEntities> .GetManager(DataConnection.EFConnectionName, true))
            {
                CompanyContactPhones newContactPhone = new CompanyContactPhones();
                newContactPhone.CompanyContactPhoneId = ReadProperty(CompanyContactPhoneIdProperty);
                newContactPhone.EntityKey             = new System.Data.EntityKey("RolodexEntities.CompanyContactPhones", "CompanyContactPhoneId", ReadProperty(CompanyContactPhoneIdProperty));
                manager.ObjectContext.Attach(newContactPhone);
                entityContact.CompanyContactPhones.Attach(newContactPhone);

                newContactPhone.FaxNumber   = ReadProperty(FaxNumberProperty);
                newContactPhone.PhoneNumber = ReadProperty(PhoneNumberProperty);
            }
        }
Ejemplo n.º 2
0
 private void Child_DeleteSelf(CompanyContact companyContact, CompanyContacts entityContact)
 {
     if (!this.IsNew)
     {
         using (ObjectContextManager <RolodexEntities> manager = ObjectContextManager <RolodexEF.RolodexEntities> .GetManager(DataConnection.EFConnectionName, true))
         {
             CompanyContactPhones deleted = new CompanyContactPhones();
             deleted.CompanyContactPhoneId = ReadProperty(CompanyContactPhoneIdProperty);
             deleted.EntityKey             = new System.Data.EntityKey("RolodexEntities.CompanyContactPhones", "CompanyContactPhoneId", deleted.CompanyContactPhoneId);
             manager.ObjectContext.Attach(deleted);
             entityContact.CompanyContactPhones.Attach(deleted);
             manager.ObjectContext.DeleteObject(deleted);
         }
     }
 }
Ejemplo n.º 3
0
 private void Child_Insert(CompanyContact companyContact, CompanyContacts entityContact)
 {
     using (ObjectContextManager <RolodexEntities> manager = ObjectContextManager <RolodexEF.RolodexEntities> .GetManager(DataConnection.EFConnectionName, true))
     {
         LoadProperty(CompanyContactIdProperty, companyContact.CompanyContactId);
         CompanyContactPhones newContactPhone = new CompanyContactPhones();
         newContactPhone.FaxNumber       = ReadProperty(FaxNumberProperty);
         newContactPhone.PhoneNumber     = ReadProperty(PhoneNumberProperty);
         newContactPhone.CompanyContacts = entityContact;
         manager.ObjectContext.AddToCompanyContactPhones(newContactPhone);
         newContactPhone.PropertyChanged += newContactPhone_PropertyChanged;
         if (ReadProperty(CompanyContactIdProperty) == 0)
         {
             entityContact.PropertyChanged += entityContact_PropertyChanged;
         }
     }
 }