本文介绍了动态Linq查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个返回List< Dictionary< string,object>>的函数。
此列表的示例如下所示
{("Source","srchostname1"),("Destination","destination"),("State", ),("Created",01/02/2010 12:32:20 pm),("Source","srchostname2"),("Destination","destination2"),("State", "错误"),("创建",02/02/2010 12:32:20 pm),("Source","srchostname3"),
("Destination","destination3"和),("状态","错误"),("创建",04/02/2010 12:32:20 pm)}
此列表将包含-1000个此类条目。
我希望能够根据"来源"进行过滤。 "目的地" "状态" "创建" ;.此过滤器基于用户的选择。它可以是上述任何一种的组合。我也希望能够通过以上任何一种方式进行订购。我也想要
能够"排序"根据用户的选择升序或降序。我还想在结果集上使用Paging。
如何使用动态linq查询来实现上述目标。我正在谷歌搜索,我看到一些PredicateBuilder类可用于过滤器(where子句) part。谁能帮助我如何使用PredicateBuilder类或任何其他方式实现上述目的。
此列表的示例如下所示
{("Source","srchostname1"),("Destination","destination"),("State", ),("Created",01/02/2010 12:32:20 pm),("Source","srchostname2"),("Destination","destination2"),("State", "错误"),("创建",02/02/2010 12:32:20 pm),("Source","srchostname3"),
("Destination","destination3"和),("状态","错误"),("创建",04/02/2010 12:32:20 pm)}
此列表将包含-1000个此类条目。
我希望能够根据"来源"进行过滤。 "目的地" "状态" "创建" ;.此过滤器基于用户的选择。它可以是上述任何一种的组合。我也希望能够通过以上任何一种方式进行订购。我也想要
能够"排序"根据用户的选择升序或降序。我还想在结果集上使用Paging。
如何使用动态linq查询来实现上述目标。我正在谷歌搜索,我看到一些PredicateBuilder类可用于过滤器(where子句) part。谁能帮助我如何使用PredicateBuilder类或任何其他方式实现上述目的。
解决方案
I have a function which returns a List<Dictionary<string, object>>.
An example of this list would look like this
{ ("Source", "srchostname1"), ("Destination", "destination"), ("State","Transferring"), ("Created",01/02/2010 12:32:20pm) , ("Source", "srchostname2"), ("Destination", "destination2"), ("State","Error"), ("Created",02/02/2010 12:32:20pm), ("Source", "srchostname3"), ("Destination", "destination3"), ("State","Error"), ("Created",04/02/2010 12:32:20pm) }
This list would contains -1000- of such entries.
I would like to be able filter based on "Source" "Destination" "State" "Created". This filter is based on user's choice. It can be a combination of any of the above. I would also like to be able to orderby any of the above. I would also like to be able to "Sort" Ascending or descending based on user's choice. I would also like to use Paging on the result set.
How to use a dynamic linq query to achieve the above. I'm googling and i see some PredicateBuilder class available for the filter (where clause) part. Can anyone help me on how i can achieve the above using PredicateBuilder class or any other way.
An example of this list would look like this
{ ("Source", "srchostname1"), ("Destination", "destination"), ("State","Transferring"), ("Created",01/02/2010 12:32:20pm) , ("Source", "srchostname2"), ("Destination", "destination2"), ("State","Error"), ("Created",02/02/2010 12:32:20pm), ("Source", "srchostname3"), ("Destination", "destination3"), ("State","Error"), ("Created",04/02/2010 12:32:20pm) }
This list would contains -1000- of such entries.
I would like to be able filter based on "Source" "Destination" "State" "Created". This filter is based on user's choice. It can be a combination of any of the above. I would also like to be able to orderby any of the above. I would also like to be able to "Sort" Ascending or descending based on user's choice. I would also like to use Paging on the result set.
How to use a dynamic linq query to achieve the above. I'm googling and i see some PredicateBuilder class available for the filter (where clause) part. Can anyone help me on how i can achieve the above using PredicateBuilder class or any other way.
解决方案
这篇关于动态Linq查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-13 06:46