0
phone = From objPhone As PersonPhoneEntity In sortedPhoneList
Where objPhone.PersonPhone.EffectiveEndDate > DateTime.Now And
objPhone.PersonPhone.EffectiveStartDate <= DateTime.Now 
Order By objPhone.PersonPhone.EffectiveEndDate Descending

现在我需要为 EffectiveStartDate 添加第二个按参数排序,然后按上面的结束日期排序。我尝试在 to order by 之间简单地放置一个昏迷,因为这是 resharper 和 vs2010 所接受的,但是当我调试它时这似乎不起作用。我将感谢任何人帮助我找到按 2 个变量排序的正确方法。

4

1 回答 1

0

如果我理解你的话(首先按EffectiveStartDate,然后按EffectiveEndDate(降序)它应该是这样的:

phone = From objPhone As PersonPhoneEntity In sortedPhoneList 
        Where objPhone.PersonPhone.EffectiveEndDate > DateTime.Now
          And objPhone.PersonPhone.EffectiveStartDate <= DateTime.Now 
        Order By objPhone.PersonPhone.EffectiveStartDate,
                 objPhone.PersonPhone.EffectiveEndDate Descending

在子句之后,您可以重复以逗号分隔的Order By列名(可能后跟)。Descending

于 2013-08-02T20:58:30.043 回答