Export (0) Print
Expand All

EntityDataSource.WhereParameters Property

Gets the collection of parameters that are used to create the WHERE clause.

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

'Declaration
<BrowsableAttribute(False)> _
<PersistenceModeAttribute(PersistenceMode.InnerProperty)> _
Public ReadOnly Property WhereParameters As ParameterCollection

Property Value

Type: System.Web.UI.WebControls.ParameterCollection
The parameters that are used for creating the WHERE clause.

Implements

IDynamicDataSource.WhereParameters

Like the Where method of the ObjectQuery(Of T) class, parameters can be passed to the predicate assigned to the Where property. The WhereParameters property of the EntityDataSource control specifies a ParameterCollection that contains the parameters to supply to the WHERE clause of the query. The WhereParameters property uses named arguments to refer to the parameters that are specified in the string that is supplied to the Where property.

If the WhereParameters property is not set, no parameter substitution is made. All the parameter names in the WHERE clause preceded by the symbol "@" must have a matching name in the ParameterCollection. Null values are not allowed for parameters in a ParameterCollection.

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(Of 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