संपादित करें

इसके माध्यम से साझा किया गया


Queryable.Order Method

Definition

Overloads

Order<T>(IQueryable<T>)

Sorts the elements of a sequence in ascending order.

Order<T>(IQueryable<T>, IComparer<T>)

Sorts the elements of a sequence in ascending order.

Order<T>(IQueryable<T>)

Source:
Queryable.cs
Source:
Queryable.cs
Source:
Queryable.cs

Sorts the elements of a sequence in ascending order.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IOrderedQueryable<T> ^ Order(System::Linq::IQueryable<T> ^ source);
public static System.Linq.IOrderedQueryable<T> Order<T> (this System.Linq.IQueryable<T> source);
static member Order : System.Linq.IQueryable<'T> -> System.Linq.IOrderedQueryable<'T>
<Extension()>
Public Function Order(Of T) (source As IQueryable(Of T)) As IOrderedQueryable(Of T)

Type Parameters

T

The type of the elements of source.

Parameters

source
IQueryable<T>

A sequence of values to order.

Returns

An IOrderedEnumerable<TElement> whose elements are sorted.

Exceptions

source is null.

Remarks

This method has at least one parameter of type Expression<TDelegate> whose type argument is one of the Func<T,TResult> types. For these parameters, you can pass in a lambda expression and it will be compiled to an Expression<TDelegate>.

The Order<T>(IQueryable<T>) method generates a MethodCallExpression that represents calling Order<T>(IEnumerable<T>) itself as a constructed generic method. It then passes the MethodCallExpression to the CreateQuery<TElement>(Expression) method of the IQueryProvider represented by the Provider property of the source parameter. The result of calling CreateQuery<TElement>(Expression) is cast to type IOrderedQueryable<T> and returned.

The query behavior that occurs as a result of executing an expression tree that represents calling Order<T>(IEnumerable<T>) depends on the implementation of the source parameter. The expected behavior is that it sorts the elements of source by itself.

Applies to

Order<T>(IQueryable<T>, IComparer<T>)

Source:
Queryable.cs
Source:
Queryable.cs
Source:
Queryable.cs

Sorts the elements of a sequence in ascending order.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IOrderedQueryable<T> ^ Order(System::Linq::IQueryable<T> ^ source, System::Collections::Generic::IComparer<T> ^ comparer);
public static System.Linq.IOrderedQueryable<T> Order<T> (this System.Linq.IQueryable<T> source, System.Collections.Generic.IComparer<T> comparer);
static member Order : System.Linq.IQueryable<'T> * System.Collections.Generic.IComparer<'T> -> System.Linq.IOrderedQueryable<'T>
<Extension()>
Public Function Order(Of T) (source As IQueryable(Of T), comparer As IComparer(Of T)) As IOrderedQueryable(Of T)

Type Parameters

T

The type of the elements of source.

Parameters

source
IQueryable<T>

A sequence of values to order.

comparer
IComparer<T>

An IComparer<T> to compare elements.

Returns

An IOrderedEnumerable<TElement> whose elements are sorted.

Exceptions

source is null.

Remarks

This method has at least one parameter of type Expression<TDelegate> whose type argument is one of the Func<T,TResult> types. For these parameters, you can pass in a lambda expression and it will be compiled to an Expression<TDelegate>.

The Order<T>(IQueryable<T>) method generates a MethodCallExpression that represents calling Order<T>(IEnumerable<T>) itself as a constructed generic method. It then passes the MethodCallExpression to the CreateQuery<TElement>(Expression) method of the IQueryProvider represented by the Provider property of the source parameter. The result of calling CreateQuery<TElement>(Expression) is cast to type IOrderedQueryable<T> and returned.

The query behavior that occurs as a result of executing an expression tree that represents calling Order<T>(IEnumerable<T>) depends on the implementation of the source parameter. The expected behavior is that it sorts the elements of source by itself.

Applies to