Export (0) Print
Expand All

EntityDataSource.Where Property

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

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

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

Property Value

Type: System.String
The WHERE clause.

Implements

IDynamicDataSource.Where

The Where property of the EntityDataSource control is a string that represents a WHERE clause that is the predicate of an Entity SQL query. This string is passed, without modification, to an ObjectQuery<T> that is executed by the Entity Framework. This query is the source of the data regulated by the EntityDataSource control. The string supplied to the Where property uses the same format as the string that is passed to the Where method of ObjectQuery<T>. For examples of how to use the WHERE clause to filter a query, see How to: Filter Data (Entity Framework).

To filter query results by equating an entity type property to an expression, see information about the AutoGenerateWhereClause property.

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" 
  ConnectionString="name=AdventureWorksEntities" 
  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">
  <WhereParameters>
    <asp:ControlParameter ControlID="costLimit" DbType="Int32" 
      DefaultValue="2500" Name="ordercost" PropertyName="Text" />
  </WhereParameters>
</asp:EntityDataSource>

The previous XML example is the same as the following ObjectQuery<T> named onlineOrders:

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

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft