当用户从“详细信息”中删除数据时,如何将数据从“详细信息”表移动到“LogDetail”?
我正在使用EF 6,MVC 5和DB First方法
从控制器删除操作
public ActionResult DeleteConfirmed(MyViewModel model)
{
DetailPengiriman detailPengiriman = db.DetailPengirimen.Find(model.TransID);
db.DetailPengirimen.Remove(detailPengiriman);
db.SaveChanges();
return RedirectToAction("Index", new { compID = model.compID });
}
我可以使用SQL Server的触发器以及如何操作吗?谢谢
答案 0 :(得分:0)
您需要的是for delete trigger
CREATE TRIGGER <trigger_name>
ON Detail
FOR DELETE
AS
INSERT INTO LogDetail <column_list>
SELECT <column_list>
FROM DELETED