private TicketEntities Fill(tblContacts contact) { log.Debug(string.Format("Begin Fill({0})", contact.FileNum)); try { var Id = contact.FileNum; var result = new TicketEntities { Contact = contact, Attachments = context.tblAttachments.Where(a => a.FileNum == Id).ToList(), ResponseHistory = context.tblContactHistory.Where(a => a.FileNum == Id).ToList(), ResearchHistory = context.tblResearchHistory.Where(a => a.FileNum == Id).ToList(), IncidentUpdateHistory = context.tblIncidentUpdateHistory.Where(a => a.FileNum == Id).ToList(), LinkedContacts = context.tblLinkedContacts.Where(a => a.FileNum == Id).ToList(), ChangeHistory = context.tblUpdateLog.Where(a => a.FileNum == Id).ToList(), }; if (DetachGet) { log.Debug(string.Format("Detaching new TicketEntities")); result.Detach(context); } return(result); } finally { log.Debug(string.Format("End Fill({0})", contact.FileNum)); } }
public TicketEntities GetContact(int Id) { var result = new TicketEntities { Contact = context.tblContacts.FirstOrDefault(c => c.FileNum == Id) }; if (!DetachGet) { return(result); } log.Debug(string.Format("Detaching {0}", result.Contact.FileNum)); result.Detach(context); return(result); }