This documentation is archived and is not being maintained.

EntityDataSource.OrderBy Property

Gets or sets the Entity SQL expression that specifies how to order the query results.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web.Entity (in System.Web.Entity.dll)

public string OrderBy { get; set; }
<asp:EntityDataSource OrderBy="String" />

Property Value

Type: System.String
The ORDER BY clause.

The OrderBy property of the EntityDataSource control is a string that represents an ORDER BY expression of an Entity SQL query. This string is passed, without modification, to an ObjectQuery<T> that is executed by Object Services. This query is the source of the data regulated by the EntityDataSource control. The string supplied to the OrderBy property uses the same format as the string that is passed to the OrderBy method of ObjectQuery<T>. For examples of how to use the ORDER BY clause to order query results, see How to: Sort Data (Entity Framework).

The XML markup in the following example, in an .aspx file, retrieves a value from a control and passes it as a parameter to the Where property.

<asp:EntityDataSource ID="SalesOrderHeader" runat="server" 
  DefaultContainerName="AdventureWorksEntities" EnableDelete="True" 
  EnableInsert="True" EnableUpdate="True" EntitySetName="SalesOrderHeader" 
  EntityTypeFilter="" OrderBy="it.TotalDue DESC" Select="" 
   Where="it.OnlineOrderFlag = TRUE AND it.TotalDue &gt; @ordercost">
    <asp:ControlParameter ControlID="costLimit" DbType="Int32" 
      DefaultValue="2500" Name="ordercost" PropertyName="Text" />

The previous XML example is equivalent to the following ObjectQuery<T> named onlineOrders:

ObjectQuery<SalesOrderHeader> onlineOrders =
       .Where("it.OnlineOrderFlag = TRUE AND it.TotalDue > @ordercost",
         new ObjectParameter("ordercost", orderCost))
        .OrderBy("it.TotalDue DESC");

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5 SP1