protected void btnDelete_Click(object sender, EventArgs e) { int id = 1; MagnumEntities db = new MagnumEntities(); User u = db.Users.FirstOrDefault(x => x.ID == id); db.Users.Remove(u); db.SaveChanges(); }
protected void btnAdd_Click(object sender, EventArgs e) { MagnumEntities db = new MagnumEntities(); User u = new User(); u.Name = TextBox1.Text; db.Users.Add(u); db.SaveChanges(); }
protected void btnUpdate_Click(object sender, EventArgs e) { int id = 1; MagnumEntities db = new MagnumEntities(); User u = db.Users.Find(id); if (u == null) { } else { u.Name = "KK"; db.SaveChanges(); } }