我有一个现有的 LINQ 查询来检索一些项目:
var result = from foo in x.SomeThings
from bar in x.OtherThings
where foo.RefId == bar.RefId
select foo;
x 是一个包含三个属性的对象:
List<MyThing> SomeThings
List<MyThing> OtherThings
List<MyStuff> MyStuffs
包含一个也是 MyThing 的属性。
以下是课程的概述:
public class X
{
public List<MyThing> SomeThings;
public List<MyThing> OtherThings;
public List<MyStuff> MyStuffs;
}
public class MyThing
{
public int RefId;
}
public class MyStuff
{
public MyThing TheThing;
public DateTime WhenHappened;
}
如何根据匹配的 RefId 值,根据 WhenHappened 的最早值对返回的 foo 进行排序?