0

TSQL と同じように:

select * from aTable where (aCondition) order by AnIntegerField desc, ADateField 

以下を使用して DataTable をソートする方法:

dt.AsEnumerable().OrderBy(--two conditions --)
4

1 に答える 1

4

最初にOrderByを使用し、次にThenBy(昇順の場合)またはThenByDescending(降順の場合)を使用します。

Microsoftのドキュメントから:

    string[] fruits = { "grape", "passionfruit", "banana", "mango", 
                          "orange", "raspberry", "apple", "blueberry" };

    // Sort the strings first by their length and then 
    //alphabetically by passing the identity selector function.
    IEnumerable<string> query =
        fruits.OrderBy(fruit => fruit.Length).ThenBy(fruit => fruit);

またはVBの場合(質問は両方でタグ付けされているため):

    ' Create an array of strings.
    Dim fruits() As String = _
        {"grape", "passionfruit", "banana", "mango", _
         "orange", "raspberry", "apple", "blueberry"}

    ' Sort the strings first by their length and then 
    ' alphabetically by passing the identity function.
    Dim query As IEnumerable(Of String) = _
        fruits _
        .OrderBy(Function(fruit) fruit.Length) _
        .ThenBy(Function(fruit) fruit)
于 2012-07-29T00:05:04.610 に答える