改进/修改 LINQ 查询
我已经有一个包含一些组的变量。我使用以下 LINQ 查询生成了它:
var historyGroups = from payee in list
group payee by payee.Payee.Name into groups
orderby groups.Key
select new {PayeeName = groups.Key, List = groups };
现在我的 HistoryGroups 变量可以包含许多组。每个组都有一个字符串键,结果视图根据该键进行排序。现在,在每个组内都有一个与该键对应的列表。在该 List 内部有一些元素,每个元素都是一种特定类型的对象。它的字段之一是 System.DateTime 类型。我想按日期对这个内部列表进行排序。
谁能帮忙解决这个问题吗?可以修改上面的查询或对变量historyGroups进行新的查询。
谢谢
I already have a variable containing some groups. I generated that using the following LINQ query:
var historyGroups = from payee in list
group payee by payee.Payee.Name into groups
orderby groups.Key
select new {PayeeName = groups.Key, List = groups };
Now my historyGroups variable can contain many groups. Each of those groups has a key which is a string and Results View is sorted according to that. Now inside each of those groups there is a List corresponding to the key. Inside that List there are elements and each one those element is an object of a particular type. One of it's fields is of type System.DateTime. I want to sort this internal List by date.
Can anyone help with this? May be modify the above query or a new query on variable historyGroups.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不清楚您想要对什么进行排序(也缺少收款人类型定义)
是最直接的。
如果您确实只想按日期(而不是时间)排序,请使用
SomeDateTimeField.Date
。这让我可能(?)怀疑
或者甚至
我希望下次你能更好地澄清这个问题,所以我们不必猜测那么多(并提出一个令人困惑的答案)
It is not clear to me what you want to sort on (the payee type definition is missing as well)
Is most straightforward.
If you really want to sort only by date (and not time), use
SomeDateTimeField.Date
.This leads me to maybe(?) suspect
Or perhaps even
I hope next time you can clarfy the question a bit better, so we don't have to guess that much (and come up with a confusing answer)