如何在mvc上使用cascade删除?

时间:2012-06-04 04:59:13

标签: database asp.net-mvc-3 cascade

如何在mvc上使用级联引用删除,以便删除两个表?

public ActionResult Delete(int appointmentid)
{
    Appointment appointment = _database.Appointment.Find(appointmentid);
    if (appointment == null)
    {
        return HttpNotFound();
    }
    return View();
}

[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int appointmentid)
{
    Appointment appointment = _database.Appointment.Find(appointmentid);
    if (appointment == null)
    {
        return HttpNotFound();
    }
    _database.Appointment.Remove(appointmentid);
    _database.Appointment.SaveChanges();
    return RedirectToAction("Create");
}

这不起作用

0 个答案:

没有答案