public void Add(BusLine busLine) { using (var db = GetTrafficDataContext()) { db.BusLines.Add(busLine); db.SaveChanges(); } }
public void Update(BusLine busLine) { using (var db = GetTrafficDataContext()) { var entry = db.BusLines.Find(busLine.ID); if (entry == null) { db.BusLines.Add(busLine); } else { busLine.ID = entry.ID; db.Entry(entry).CurrentValues.SetValues(busLine); } db.SaveChanges(); } }