在asp.net MVC中,我在控制器中有一个搜索操作,我正在尝试决定是否将查询作为字符串传递给我的存储库。
或作为单独的参数:
public ActionResult Search(string query)
{
return View(_repository.ListPeople(query));
}
或作为单独的参数:
public ActionResult Search(string FirstName, string LastName, System.Nullable<byte> Education)
{
return View(_repository.ListPeople(FirstName, LastName, Education));
}
我在网上看到很多例子都使用查询字符串的方法,但对我来说它不太“安全”,尽管当你有一堆参数要传递时,使用这种方法会更容易处理。是否有普遍共识认为哪种方法更好?