我在 asp.net mvc 中有存储库类,它有这个,
public Material GetMaterial(int id)
{
return db.Materials.SingleOrDefault(m => m.Mat_id == id);
}
我的控制器有这个详细的操作结果,
ConstructionRepository consRepository = new ConstructionRepository();
public ActionResult Details(int id)
{
Material material = consRepository.GetMaterial(id);
return View();
}
但为什么我得到这个错误,
The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Details(Int32)' in 'CrMVC.Controllers.MaterialsController'. To make a parameter optional its type should be either a reference type or a Nullable type.
Parameter name: parameters
任何建议...