如何使NameValueCollectionLINQ查询运算符可以访问,例如where,join,groupby?
我试过以下:
private NameValueCollection RequestFields()
{
NameValueCollection nvc = new NameValueCollection()
{
{"emailOption: blah Blah", "true"},
{"emailOption: blah Blah2", "false"},
{"nothing", "false"},
{"nothinger", "true"}
};
return nvc;
}
public void GetSelectedEmail()
{
NameValueCollection nvc = RequestFields();
IQueryable queryable = nvc.AsQueryable();
}
Run Code Online (Sandbox Code Playgroud)
但我得到一个ArgumentException告诉我源不是IEnumerable <>.
我想在我的视图上应用不同的排序和过滤我想我将通过查询字符串传递排序和过滤参数:
@Html.ActionLink("Name", "Index", new { SortBy= "Name"})
Run Code Online (Sandbox Code Playgroud)
这种简单的结构允许我排序.View在查询字符串中返回:
?SortBy=Name
Run Code Online (Sandbox Code Playgroud)
现在我想添加过滤,我希望我的查询字符串最终结束
?SortBy=Name&Filter=Something
Run Code Online (Sandbox Code Playgroud)
如何将其他参数添加到已存在的列表中ActionLink?例如:
user requests /Index/
Run Code Online (Sandbox Code Playgroud)
视图有
@Html.ActionLink("Name", "Index", new { SortBy= "Name"})
Run Code Online (Sandbox Code Playgroud)
和
@Html.ActionLink("Name", "Index", new { FilterBy= "Name"})
Run Code Online (Sandbox Code Playgroud)
链接:第一个看起来像/Index/?SortBy=Name,第二个是 /Index/?FilterBy=Name
我希望当用户按下排序链接后他应用了一些过滤 - 过滤不会丢失,所以我需要一种方法来组合我的参数.我的猜测是应该有一种方法不解析查询字符串,但从一些MVC对象获取参数集合.