Aracılığıyla paylaş


Queryable.ThenBy Yöntem

Tanım

Öğelerin sonraki sıralamasını artan düzende sıralı olarak gerçekleştirir.

Aşırı Yüklemeler

Name Description
ThenBy<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ı artan düzende gerçekleştirir.

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

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

ThenBy<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ı artan düzende gerçekleştirir.

public:
generic <typename TSource, typename TKey>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IOrderedQueryable<TSource> ^ ThenBy(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> ThenBy<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> ThenBy<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> ThenBy<TSource,TKey>(this System.Linq.IOrderedQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector, System.Collections.Generic.IComparer<TKey>? comparer);
static member ThenBy : 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 ThenBy : System.Linq.IOrderedQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, 'Key>> * System.Collections.Generic.IComparer<'Key> -> System.Linq.IOrderedQueryable<'Source>
<Extension()>
Public Function ThenBy(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

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.

comparer
IComparer<TKey>

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

Döndürülenler

IOrderedQueryable<T> Öğeleri bir anahtara göre sıralanmış olan.

Öznitelikler

Özel durumlar

source veya keySelector veya comparer ş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, 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 her öğesinde çağrılarak keySelector elde edilen anahtara göre öğelerinin source ikincil bir sıralamasını gerçekleştirmesidirsource. Ö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

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

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

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

public:
generic <typename TSource, typename TKey>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IOrderedQueryable<TSource> ^ ThenBy(System::Linq::IOrderedQueryable<TSource> ^ source, System::Linq::Expressions::Expression<Func<TSource, TKey> ^> ^ keySelector);
public static System.Linq.IOrderedQueryable<TSource> ThenBy<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> ThenBy<TSource,TKey>(this System.Linq.IOrderedQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector);
static member ThenBy : 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 ThenBy : System.Linq.IOrderedQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, 'Key>> -> System.Linq.IOrderedQueryable<'Source>
<Extension()>
Public Function ThenBy(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 sıralanmış olan.

Öznitelikler

Özel durumlar

source veya keySelector şeklindedir null.

Örnekler

Aşağıdaki kod örneği, bir dizideki öğelerin ikincil sıralamasını gerçekleştirmek için nasıl kullanılacağını ThenBy<TSource,TKey>(IOrderedQueryable<TSource>, Expression<Func<TSource,TKey>>) gösterir.

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

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

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

/*
    This code produces the following output:

    apple
    grape
    mango
    banana
    orange
    blueberry
    raspberry
    passionfruit
*/
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 selector function.
Dim query = fruits.AsQueryable() _
    .OrderBy(Function(fruit) fruit.Length).ThenBy(Function(fruit) fruit)

' Display the results.
Dim output As New System.Text.StringBuilder
For Each fruit As String In query
    output.AppendLine(fruit)
Next
MsgBox(output.ToString())

'This code produces the following output:

'apple
'grape
'mango
'banana
'orange
'blueberry
'raspberry
'passionfruit

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>>) kendisini oluşturulan genel bir MethodCallExpression yöntem olarak çağıran ThenBy<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ı ThenBy<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 her öğesinde çağrılarak keySelector elde edilen anahtara göre öğelerinin source ikincil bir sıralamasını gerçekleştirmesidirsource. Önceden oluşturulmuş tüm sıralama düzenleri korunur.

Şunlara uygulanır