Hi, I’ve got a database that stores Contact details mainly in four tables:
Person, Contact, Phone, Email
So when the users wants to add a new Contact it starts by adding a New person, then the PersonID is used in creating the new contact and the ContactID is then used on each Phone and Email added to these tables… So I’m thinking of doing something like:
ContactsEntities newContactsEntities = new ContactsEntities();
Person newPerson = new Person();
PersonDAL.Add(newPerson);
Contact newContact = new Contact();
newContact.PersonID = newContactsEntities.Person.Max(x => x.PersonID);
ContactDAL.Add(newContact);
Phone newPhone = new Phone();
newPhone.ContactID = newContactsEntities.Contact.Max(y => y.ContactID);
PhoneDAL.Add(newPhone);
Email newEmail = new Email();
newEmail.ContactID = newContactsEntities.Contact.Max(z => z.ContactID);
EmailDAL.Add(newEmail);
Is this a good solution or I’m missing something important here?