示例#1
0
 public void Add(BusLine busLine)
 {
     using (var db = GetTrafficDataContext())
     {
         db.BusLines.Add(busLine);
         db.SaveChanges();
     }
 }
示例#2
0
 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();
     }
 }