DbExpressionBuilder.OrderBy Method

Definition

Creates a new DbSortExpression that sorts the given input set by the specified sort key, with ascending sort order and default collation.

Overloads

OrderBy(DbExpression, Func<DbExpression,DbExpression>)

Creates a new DbSortExpression that sorts the given input set by the specified sort key, with ascending sort order and default collation.

OrderBy(DbExpression, Func<DbExpression,DbExpression>, String)

Creates a new DbSortExpression that sorts the given input set by the specified sort key, with ascending sort order and the specified collation.

OrderBy(DbExpression, Func<DbExpression,DbExpression>)

Creates a new DbSortExpression that sorts the given input set by the specified sort key, with ascending sort order and default collation.

C#
public static System.Data.Common.CommandTrees.DbSortExpression OrderBy(this System.Data.Common.CommandTrees.DbExpression source, Func<System.Data.Common.CommandTrees.DbExpression,System.Data.Common.CommandTrees.DbExpression> sortKey);

Parameters

source
DbExpression

An expression that specifies the input set.

sortKey
Func<DbExpression,DbExpression>

A method that specifies how to derive the sort key expression given a member of the input set. This method must produce an expression with an order-comparable result type that provides the sort key definition.

Returns

A new DbSortExpression that represents the order-by operation.

Exceptions

source or sortKey is null.

-or-

The expression produced by sortKey is null.

source does not have a collection result type.

-or-

The expression produced by sortKey does not have an order-comparable result type.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

OrderBy(DbExpression, Func<DbExpression,DbExpression>, String)

Creates a new DbSortExpression that sorts the given input set by the specified sort key, with ascending sort order and the specified collation.

C#
public static System.Data.Common.CommandTrees.DbSortExpression OrderBy(this System.Data.Common.CommandTrees.DbExpression source, Func<System.Data.Common.CommandTrees.DbExpression,System.Data.Common.CommandTrees.DbExpression> sortKey, string collation);

Parameters

source
DbExpression

An expression that specifies the input set.

sortKey
Func<DbExpression,DbExpression>

A method that specifies how to derive the sort key expression given a member of the input set. This method must produce an expression with an order-comparable result type that provides the sort key definition.

collation
String

The collation to sort under.

Returns

A new DbSortExpression that represents the order-by operation.

Exceptions

source, sortKey or collation is null.

-or-

The expression produced by sortKey is null.

source does not have a collection result type.

-or-

The expression produced by sortKey does not have an order-comparable string result type.

collation is empty or contains only space characters.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1