public static Division FetchOrCreateDivision(CMSDataContext Db, Program program, string division) { var d = Db.Divisions.SingleOrDefault(pp => pp.Name == division && pp.ProgDivs.Any(pd => pd.ProgId == program.Id)); if (d == null) { d = new Division { Name = division, Program = program }; var progdiv = new ProgDiv { Division = d, Program = program }; Db.ProgDivs.InsertOnSubmit(progdiv); Db.SubmitChanges(); } else { var pd = Db.ProgDivs.SingleOrDefault(dd => dd.ProgId == program.Id && dd.DivId == d.Id); if (pd == null) { program.Divisions.Add(d); } Db.SubmitChanges(); } return(d); }
public static Division FetchOrCreateDivision(CMSDataContext Db, Program program, string division) { var d = Db.Divisions.SingleOrDefault(pp => pp.Name == division); if (d == null) { d = new Division { Name = division, Program = program }; var progdiv = new ProgDiv { Division = d, Program = program }; Db.ProgDivs.InsertOnSubmit(progdiv); Db.SubmitChanges(); } return(d); }
public static Division FetchOrCreateDivision(CMSDataContext Db, Program program, string division) { var d = Db.Divisions.SingleOrDefault(pp => pp.Name == division && pp.ProgDivs.Any(pd => pd.ProgId == program.Id)); if (d == null) { d = new Division { Name = division, Program = program }; var progdiv = new ProgDiv { Division = d, Program = program }; Db.ProgDivs.InsertOnSubmit(progdiv); Db.SubmitChanges(); } else { var pd = Db.ProgDivs.SingleOrDefault(dd => dd.ProgId == program.Id && dd.DivId == d.Id); if (pd == null) program.Divisions.Add(d); Db.SubmitChanges(); } return d; }
private void detach_ProgDivs(ProgDiv entity) { this.SendPropertyChanging(); entity.Division = null; }
private void attach_ProgDivs(ProgDiv entity) { this.SendPropertyChanging(); entity.Division = this; }
private void detach_ProgDivs(ProgDiv entity) { this.SendPropertyChanging(); entity.Program = null; }
private void attach_ProgDivs(ProgDiv entity) { this.SendPropertyChanging(); entity.Program = this; }