End Google Ads 201810 - BS.net 01 --> I was able to get my code to work with the following, but it seems inefficient. Isn't this code calling the database multiple times to get objects before an insert. Anyone know the correct way to do this or have a link with a good example?


int baRequestTypeId = int.Parse(this.rblMode.SelectedValue);
int baAssociateTypeId = int.Parse(this.rcbAssociateType.SelectedValue);
int baBusinessTypeId = int.Parse(this.rcbBusinessType.SelectedValue);



SqlData.BusinessAssociateWorkFlowData dataContext = new BusinessAssociateWorkFlow.SqlData.BusinessAssociateWorkFlowData();
SqlData.BusinessAssociateContactChangeRequest baContact = new BusinessAssociateWorkFlow.SqlData.BusinessAssociateContactChangeRequest();

SqlData.RequestType baRequestType = (from r in dataContext.RequestType
where r.RequestTypeId == baRequestTypeId
select r).First();

SqlData.BusinessAssociateType baBusinessAssociateType = (from b in dataContext.BusinessAssociateType
where b.BusinessAssociateTypeId == baAssociateTypeId
select b).First();


SqlData.BusinessType baBusinessType = (from b in dataContext.BusinessType
where b.BusinessTypeId == baBusinessTypeId
select b).First();
baContact.RequestType = baRequestType;
baContact.BusinessAssociateType = baBusinessAssociateType;
baContact.BusinessType = baBusinessType;
baContact.Name = this.rtbName.Text;
baContact.Abbreviation = this.rtbAbbreviation.Text;
baContact.Code = this.rtbCode.Text;
baContact.CreatedBy = User.Identity.Name;
baContact.CreatedOn = DateTime.Now;
baContact.LastModifiedBy = User.Identity.Name;
baContact.LastModifiedOn = DateTime.Now;
baContact.ContactAddress.Add(this.AddressCntrl1.GetContactAddressEntity(ref dataContext));
dataContext.SaveChanges();


I didn't get any requirements for the signature