我的两个过滤链接:
@Html.ActionLink("Customer 1", "Index", new { customer = 1 })
@Html.ActionLink("Project A", "Index", new { project = "A" })
我的带有过滤功能的控制器:
public ViewResult Index(int? customer, int? project) {
var query = ...
if (customer != null) {
query = query.Where(o => o.CustomerID == customer);
}
if (project != null) {
query = query.Where(o => o.ProjectID == project);
}
return View(query.ToList());
}
我现在可以过滤客户或项目,但不能同时过滤两者!
如果我点击客户 1,url = Object?customer=1
如果我点击项目 A,url = Object?project=a
我希望能够先单击客户 1,然后单击项目 A 并获得url = Object?customer=1&project=a
这是可能的还是我应该以其他方式做到这一点?
谢谢!