LINQ OrderByDescending 传递字符串值
您好,我正在尝试对查询进行 OrderByDescending()
,而不是:
results = results.OrderByDescending(o => o.Surname);
我希望使用:
results = results.OrderByDescending(o => "Surname");
引号中的值将在参数中传递。
我正在查看反射,但不确定。
Hi I am trying to OrderByDescending()
on a query but rather than:
results = results.OrderByDescending(o => o.Surname);
I wish to use:
results = results.OrderByDescending(o => "Surname");
The value in quotes would be passed in in a parameter.
I was looking at reflection but am unsure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下 LINQ 动态查询库: http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query- library.aspx
这将允许您使用
results.OrderByDescending("Surname");
Have a look at LINQ Dynamic Query Library: http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx
this will allow you to use
results.OrderByDescending("Surname");
我用这样的东西
I use something like this