新建ASP.NET相关技术交流群205914059 //ef类 GpsWebContext gdb = new GpsWebContext(); //////查 /// ///数据结果 public IList <实体类名> Gps_AlarmInfoList() { return gdb.Gps_AlarmInfo.ToList(); } //增加 public bool Add(实体类名 m) { bool flag = false; try { gdb.实体类名.Add(m); gdb.SaveChanges(); flag = true; } catch (Exception ee) { throw ee.InnerException; } return flag; } //修改 public bool Edit(实体类名 m) { bool flag = false; try { gdb.Entry(m).State = EntityState.Modified; gdb.SaveChanges(); flag = true; } catch (Exception ee) { throw ee.InnerException; } return flag; } //删除 public bool Del(int id) { bool flag = false; try { gdb.实体类名.Remove(gdb.实体类名.Find(id)); gdb.SaveChanges(); flag = true; } catch (Exception ee) { throw ee.InnerException; } return flag; } //明细 public 实体类名 Details(int id) { return gdb.实体类名.Find(id); }