Aracılığıyla paylaş


Queryable.ThenByDescending Yöntem

Tanım

Öğelerin sonraki sıralamasını azalan düzende bir sırayla gerçekleştirir.

Aşırı Yüklemeler

Name Description
ThenByDescending<TSource,TKey>(IOrderedQueryable<TSource>, Expression<Func<TSource,TKey>>)

Bir anahtara göre bir dizideki öğelerin sonraki sıralamasını azalan düzende gerçekleştirir.

ThenByDescending<TSource,TKey>(IOrderedQueryable<TSource>, Expression<Func<TSource,TKey>>, IComparer<TKey>)

Belirtilen bir karşılaştırıcıyı kullanarak bir dizideki öğelerin sonraki sıralamasını azalan sırada gerçekleştirir.

ThenByDescending<TSource,TKey>(IOrderedQueryable<TSource>, Expression<Func<TSource,TKey>>)

Kaynak:
Queryable.cs
Kaynak:
Queryable.cs
Kaynak:
Queryable.cs
Kaynak:
Queryable.cs
Kaynak:
Queryable.cs

Bir anahtara göre bir dizideki öğelerin sonraki sıralamasını azalan düzende gerçekleştirir.

public:
generic <typename TSource, typename TKey>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IOrderedQueryable<TSource> ^ ThenByDescending(System::Linq::IOrderedQueryable<TSource> ^ source, System::Linq::Expressions::Expression<Func<TSource, TKey> ^> ^ keySelector);
public static System.Linq.IOrderedQueryable<TSource> ThenByDescending<TSource,TKey>(this System.Linq.IOrderedQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")]
public static System.Linq.IOrderedQueryable<TSource> ThenByDescending<TSource,TKey>(this System.Linq.IOrderedQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector);
static member ThenByDescending : System.Linq.IOrderedQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, 'Key>> -> System.Linq.IOrderedQueryable<'Source>
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")>]
static member ThenByDescending : System.Linq.IOrderedQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, 'Key>> -> System.Linq.IOrderedQueryable<'Source>
<Extension()>
Public Function ThenByDescending(Of TSource, TKey) (source As IOrderedQueryable(Of TSource), keySelector As Expression(Of Func(Of TSource, TKey))) As IOrderedQueryable(Of TSource)

Tür Parametreleri

TSource

öğelerinin sourcetürü.

TKey

tarafından temsil edilen keySelectorişlev tarafından döndürülen anahtarın türü.

Parametreler

source
IOrderedQueryable<TSource>

IOrderedQueryable<T> Sıralanacak öğeleri içeren bir.

keySelector
Expression<Func<TSource,TKey>>

Her öğeden bir anahtar ayıklamak için bir işlev.

Döndürülenler

IOrderedQueryable<T> Öğeleri bir anahtara göre azalan düzende sıralanan bir.

Öznitelikler

Özel durumlar

source veya keySelector şeklindedir null.

Açıklamalar

Bu yöntem, tür bağımsız değişkeni türlerden Expression<TDelegate> biri olan en az bir tür parametresine Func<T,TResult> sahiptir. Bu parametreler için bir lambda ifadesi geçirebilirsiniz ve bu ifade bir Expression<TDelegate>olarak derlenir.

yöntemi, ThenByDescending<TSource,TKey>(IOrderedQueryable<TSource>, Expression<Func<TSource,TKey>>) kendisini oluşturulan genel bir MethodCallExpression yöntem olarak çağıran ThenByDescending<TSource,TKey>(IOrderedQueryable<TSource>, Expression<Func<TSource,TKey>>) bir oluşturur. Ardından parametresinin özelliği tarafından Provider temsil edilen yöntemine sourceIQueryProvider iletirMethodCallExpression.CreateQuery<TElement>(Expression) Çağrının CreateQuery<TElement>(Expression) sonucu türe IOrderedQueryable<T> döndürülür ve döndürülür.

Çağrıyı ThenByDescending<TSource,TKey>(IOrderedQueryable<TSource>, Expression<Func<TSource,TKey>>) temsil eden bir ifade ağacının yürütülmesi sonucunda oluşan sorgu davranışı, parametre türünün uygulanmasına source bağlıdır. Beklenen davranış, öğesinin source her öğesinde çağrılarak keySelector elde edilen anahtara göre öğelerinin ikincil bir sıralamasını azalan düzende gerçekleştirmesidir source. Önceden oluşturulmuş tüm sıralama düzenleri korunur.

Şunlara uygulanır

ThenByDescending<TSource,TKey>(IOrderedQueryable<TSource>, Expression<Func<TSource,TKey>>, IComparer<TKey>)

Kaynak:
Queryable.cs
Kaynak:
Queryable.cs
Kaynak:
Queryable.cs
Kaynak:
Queryable.cs
Kaynak:
Queryable.cs

Belirtilen bir karşılaştırıcıyı kullanarak bir dizideki öğelerin sonraki sıralamasını azalan sırada gerçekleştirir.

public:
generic <typename TSource, typename TKey>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IOrderedQueryable<TSource> ^ ThenByDescending(System::Linq::IOrderedQueryable<TSource> ^ source, System::Linq::Expressions::Expression<Func<TSource, TKey> ^> ^ keySelector, System::Collections::Generic::IComparer<TKey> ^ comparer);
public static System.Linq.IOrderedQueryable<TSource> ThenByDescending<TSource,TKey>(this System.Linq.IOrderedQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector, System.Collections.Generic.IComparer<TKey> comparer);
public static System.Linq.IOrderedQueryable<TSource> ThenByDescending<TSource,TKey>(this System.Linq.IOrderedQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector, System.Collections.Generic.IComparer<TKey>? comparer);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")]
public static System.Linq.IOrderedQueryable<TSource> ThenByDescending<TSource,TKey>(this System.Linq.IOrderedQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector, System.Collections.Generic.IComparer<TKey>? comparer);
static member ThenByDescending : System.Linq.IOrderedQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, 'Key>> * System.Collections.Generic.IComparer<'Key> -> System.Linq.IOrderedQueryable<'Source>
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")>]
static member ThenByDescending : System.Linq.IOrderedQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, 'Key>> * System.Collections.Generic.IComparer<'Key> -> System.Linq.IOrderedQueryable<'Source>
<Extension()>
Public Function ThenByDescending(Of TSource, TKey) (source As IOrderedQueryable(Of TSource), keySelector As Expression(Of Func(Of TSource, TKey)), comparer As IComparer(Of TKey)) As IOrderedQueryable(Of TSource)

Tür Parametreleri

TSource

öğelerinin sourcetürü.

TKey

İşlev tarafından döndürülen anahtarın keySelector türü.

Parametreler

source
IOrderedQueryable<TSource>

IOrderedQueryable<T> Sıralanacak öğeleri içeren bir.

keySelector
Expression<Func<TSource,TKey>>

Her öğeden bir anahtar ayıklamak için bir işlev.

comparer
IComparer<TKey>

Anahtarları karşılaştırmak için bir IComparer<T> .

Döndürülenler

Öğeleri bir anahtara göre azalan düzende sıralanmış bir koleksiyon.

Öznitelikler

Özel durumlar

source veya keySelector veya comparer şeklindedir null.

Örnekler

Aşağıdaki kod örneği, özel bir karşılaştırıcı kullanarak öğelerin ikincil sıralamasını azalan sırada gerçekleştirmek için nasıl kullanılacağını ThenByDescending<TSource,TKey>(IOrderedQueryable<TSource>, Expression<Func<TSource,TKey>>, IComparer<TKey>) gösterir.

public class CaseInsensitiveComparer : IComparer<string>
{
    public int Compare(string x, string y)
    {
        return string.Compare(x, y, true);
    }
}

public static void ThenByDescendingEx1()
{
    string[] fruits =
    { "apPLe", "baNanA", "apple", "APple", "orange", "BAnana", "ORANGE", "apPLE" };

    // Sort the strings first ascending by their length and
    // then descending using a custom case insensitive comparer.
    IEnumerable<string> query =
        fruits.AsQueryable()
        .OrderBy(fruit => fruit.Length)
        .ThenByDescending(fruit => fruit, new CaseInsensitiveComparer());

    foreach (string fruit in query)
        Console.WriteLine(fruit);
}

/*
    This code produces the following output:

    apPLe
    apple
    APple
    apPLE
    orange
    ORANGE
    baNanA
    BAnana
*/
Class CaseInsensitiveComparer
    Implements IComparer(Of String)

    Function Compare(ByVal x As String, ByVal y As String) As Integer _
        Implements IComparer(Of String).Compare

        ' Compare values and ignore case.
        Return String.Compare(x, y, True)
    End Function
End Class

Sub ThenByDescendingEx1()
    Dim fruits() As String = _
        {"apPLe", "baNanA", "apple", "APple", "orange", "BAnana", "ORANGE", "apPLE"}

    ' Sort the strings first ascending by their length and 
    ' then descending by using a custom case insensitive comparer.
    Dim query = fruits.AsQueryable() _
        .OrderBy(Function(fruit) fruit.Length) _
        .ThenByDescending(Function(fruit) fruit, New CaseInsensitiveComparer())

    Dim output As New System.Text.StringBuilder
    For Each fruit As String In query
        output.AppendLine(fruit)
    Next

    ' Display the results.
    MsgBox(output.ToString())
End Sub

' This code produces the following output:

' apPLe
' apple
' APple
' apPLE
' orange
' ORANGE
' baNanA
' BAnana

Açıklamalar

Bu yöntem, tür bağımsız değişkeni türlerden Expression<TDelegate> biri olan en az bir tür parametresine Func<T,TResult> sahiptir. Bu parametreler için bir lambda ifadesi geçirebilirsiniz ve bu ifade bir Expression<TDelegate>olarak derlenir.

yöntemi, ThenBy<TSource,TKey>(IOrderedQueryable<TSource>, Expression<Func<TSource,TKey>>, IComparer<TKey>) kendisini oluşturulan genel bir MethodCallExpression yöntem olarak çağıran ThenBy<TSource,TKey>(IOrderedQueryable<TSource>, Expression<Func<TSource,TKey>>, IComparer<TKey>) bir oluşturur. Ardından parametresinin özelliği tarafından Provider temsil edilen yöntemine sourceIQueryProvider iletirMethodCallExpression.CreateQuery<TElement>(Expression) Çağrının CreateQuery<TElement>(Expression) sonucu türe IOrderedQueryable<T> döndürülür ve döndürülür.

Çağrıyı ThenBy<TSource,TKey>(IOrderedQueryable<TSource>, Expression<Func<TSource,TKey>>, IComparer<TKey>) temsil eden bir ifade ağacının yürütülmesi sonucunda oluşan sorgu davranışı, parametre türünün uygulanmasına source bağlıdır. Beklenen davranış, öğesinin source her öğesinde çağrılarak keySelector elde edilen anahtara göre öğelerinin ikincil bir sıralamasını azalan düzende gerçekleştirmesidir source. Önceden oluşturulmuş tüm sıralama düzenleri korunur. comparer parametresi, anahtar değerlerini karşılaştırmak için kullanılır.

Şunlara uygulanır