이미 내 DB에서 검색 할 cityname을 나타내는 city 매개 변수가 있습니다. mysite/List? city = mycityname을 할 때 모든 것이 잘 작동하지만 뭘 하려는지 도시 이름 예 : 리스트와 결합 된 firstname으로 검색을 수행하고 싶습니다. 목록? city = mycityname & firstName = myfirstname. 어떻게해야합니까? 여기 city에 대한 쿼리가 있습니다. firstname 매개 변수도 추가했지만 실제로 추가하는 방법을 모르므로 둘 다 필터링합니다.여러 매개 변수 asp net mvc 4
public string CurrentFirstName { get; set; }
public ViewResult List(string city, string firstName, int page = 1)
{
UsersListViewModel model = new UsersListViewModel
{
Users = repository.Userss
.Where(p =>city == null || p.CityName == city)
.OrderBy(p => p.UsersId)
.Skip((page - 1) * PageSize)
.Take(PageSize),
PagingInfo = new PagingInfo
{
CurrentPage = page,
UsersPerPage = PageSize,
TotalUsers = repository.Userss.Count()
},
CurrentCity = city
// CurrentFirstName = firstName
};
return View(model);
}