public void Delete(Classandgrade classandgrade) { using (var db = new ClassContext()) { db.Entry(classandgrade).State = EntityState.Deleted; db.SaveChanges(); } }
public void Add(Classandgrade classandgrade) { using (var db = new ClassContext()) { db.Classandgrade.Add(classandgrade); db.SaveChanges(); } }
static void Delete() { Console.Write("请输入ID:"); int id = int.Parse(Console.ReadLine()); BlogBusinessLayert bbl = new BlogBusinessLayert(); Classandgrade cla = bbl.Query(id); bbl.Delete(cla); }
static void QueryClass() { Console.WriteLine("请输入一个课程:"); string b = Console.ReadLine(); Classandgrade cla = new Classandgrade(); cla.Curriculum = b; BlogBusinessLayert bbl = new BlogBusinessLayert(); bbl.Add(cla); }
static void Update() { Console.Write("请输入要修改的ID:"); int id = int.Parse(Console.ReadLine()); BlogBusinessLayert bbl = new BlogBusinessLayert(); Classandgrade cla = bbl.Query(id); Console.Write("请输入要修改的消息:"); string name = Console.ReadLine(); cla.Curriculum = name; bbl.Update(cla); }