Пример #1
0
 public Class Query(int Classid)
 {
     using (var db = new ClassgoingContext())
     {
         return(db.Classes.Find(Classid));
     }
 }
Пример #2
0
 public List <Class> Query()
 {
     using (var db = new ClassgoingContext())
     {
         var query = from b in db.Classes
                     orderby b.ClassName
                     select b;
         return(db.Classes.ToList());
     }
 }
Пример #3
0
 public void Delete(Class classed)
 {
     //设置上下文生存期
     using (var db = new ClassgoingContext())
     {
         //向上下文Blogs数据集添加一个实体(改变实体状态为添加)
         db.Entry(classed).State = EntityState.Deleted;
         //保存状态改变
         db.SaveChanges();
     }
 }
Пример #4
0
 public void Add(Class classed)
 {
     //设置上下文生存期
     using (var db = new ClassgoingContext())
     {
         //向上下文Blogs数据集添加一个实体(改变实体状态为添加)
         db.Classes.Add(classed);
         //保存状态改变
         db.SaveChanges();
     }
 }