我正在使用重定向到操作将评估模型传递给结果操作。在结果操作控制器中,我想执行一个 linq 语句来检索使用存储库的行数以及发布的任何值。例如
number of rows = Select *
from table or model
where SmokesInHouse = SmokesInHouse And
SmokesInCar = SmokesInCar And
SmokesAtWork = SmokesAtWork'
public class SampleController : Controller
{
private IEnvRepository repository;
public SampleController(IEnvRepository assesmentRepository)
{
repository = assesmentRepository;
}
[HttpPost]
public ActionResult SmokingEnvironments(Assessment a)
{
if (ModelState.IsValid)
return RedirectToAction("Results", new { SmokesInHouse =SmokesInHouse, SmokesInCar = a.SmokesInCar, SmokesAtWork=a.SmokesAtWork });
}
return View(a);
}
[HttpGet]
public ActionResult Results()
{
return View();
}
}