使用两个变量更正订单语法?

时间:2013-08-02 18:56:48

标签: vb.net linq sql-order-by vb.net-2010

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按参数添加第二个订单,然后按上面的结束日期排序。我试过简单地在命令之间放置一个昏迷,因为这就是resharper和vs2010正在接受但是当我调试它时似乎没有工作。我很感激任何帮助我找到2个变量的正确方法的人。

1 个答案:

答案 0 :(得分: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)。