我有 mvc 3 应用程序,其中在会话对象中我将我需要的所有值作为参数来执行存储过程。
如果 userAction 是更新,则执行存储过程。
public ActionResult Index(string userAction)
{
if(Session["Mappings"] != null)
ViewData["Message"] = "Mapping web grid";
if (Session["PricingSecurities"] == null)
Session["PricingSecurities"] = objRepository.GetPricingSecurityID();
if (Session["Cusips"] == null)
Session["Cusips"] = objRepository.GetCUSIP();
SecurityMappingModel objModel = null;
mappings = (List<SecurityMappingModel>)Session["Mappings"];
objModel = new SecurityMappingModel();
if (userAction == "Update" )
{
//please tell me how can i take values from Session[Mappings] and pass it to stored procedure?
return RedirectToAction("Index");
}
objModel.PricingSecirities = (List<SelectListItem>)Session["PricingSecurities"];
objModel.Cusips = (List<SelectListItem>)Session["Cusips"];
ViewBag.Mappings = mappings;
return View(objModel);
}
如何从 Session[Mappings] 中获取值并将其传递给存储过程?