private void detach_LinkedProjects1(LinkedProject entity) { this.SendPropertyChanging(); entity.ProjectInformation1 = null; }
private void attach_LinkedProjects(LinkedProject entity) { this.SendPropertyChanging(); entity.ProjectInformation = this; }
partial void DeleteLinkedProject(LinkedProject instance);
partial void UpdateLinkedProject(LinkedProject instance);
partial void InsertLinkedProject(LinkedProject instance);
public void updateLinkedProjects(String projects, CookDBDataContext db, int project_id) { try { if (projects == "") { if (db.LinkedProjects.Count(a => a.project_id.Equals(project_id)) > 0) { var wiping = db.LinkedProjects.Where(a => a.project_id.Equals(project_id)); db.LinkedProjects.DeleteAllOnSubmit(wiping); db.SubmitChanges(); } } else { //parse each project, and if that project is found, create an entry where THIS project = project_id and projects passed are sub_proj_id's var brokenUpProjects = projects.Split(','); var wiping = db.LinkedProjects.Where(a => a.project_id.Equals(project_id)); db.LinkedProjects.DeleteAllOnSubmit(wiping); db.SubmitChanges(); foreach (String i in brokenUpProjects) { if (i.Trim() != "") { if (db.ProjectInformations.Count(a => a.project_number.Equals(i.Trim())) > 0) { try { LinkedProject lp = new LinkedProject(); lp.project_id = project_id; lp.sub_project_id = db.ProjectInformations.First(a => a.project_number.Equals(i.Trim())).project_id; if (!db.LinkedProjects.Contains(lp) && lp.sub_project_id != lp.project_id) { db.LinkedProjects.InsertOnSubmit(lp); db.SubmitChanges(); } } catch (Exception) { //in case of (probably non-existant) wierd error where the proj number is found but doesnt have a proj id...ignore } } } } } } catch (Exception e) { comment += "Linked projects did not save correctly " + e.HelpLink + e.Message + e.TargetSite; } }