Export (0) Print
Expand All

EntityDataSource::AutoGenerateWhereClause Property

Gets or sets a value that indicates whether the EntityDataSource control dynamically creates a WHERE clause based on values defined in the WhereParameters collection.

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

virtual property bool AutoGenerateWhereClause {
	bool get () sealed;
	void set (bool value) sealed;
<asp:EntityDataSource AutoGenerateWhereClause="True|False" />

Property Value

Type: System::Boolean
true if the EntityDataSource control creates the WHERE clause; otherwise, false. The default value is false.




When the AutoGenerateWhereClause property is set to true and the Where property is not null.

To filter query results by equating an entity type property to an expression, you can use the AutoGenerateWhereClause property. When the AutoGenerateWhereClause property of the EntityDataSource control is set to true, the control automatically generates a WHERE clause from the parameters in the ParameterCollection of the WhereParameters property. The Name property of each parameter has to match an entity type property name that is included in the query results. If you set the AutoGenerateWhereClause property to true, you should not explicitly assign a WHERE clause to the Where property.


In the following example the AutoGenerateWhereClause property is set to true. Therefore, the Name of the property has to match an entity type property name that is included in the query results. The query selects the SalesOrderID and TotalDue properties of the SalesOrderHeader entity type. The automatically generated WHERE clause will filter the query results by comparing the TotalDue value to a value selected in the TotalDueList list box control.

<asp:EntityDataSource ID="SalesOrderHeaderWithAutoParam" runat="server" 
   Select="it.SalesOrderID, it.TotalDue"
        <asp:ControlParameter ControlID="TotalDueList" 
           Name="TotalDue" PropertyName="SelectedValue" DbType="Decimal" />


By default, the AutoGenerateWhereClause property is set to false. This means that we have to supply the WHERE clause. In the following example, the WHERE clause is Where="it.TotalDue < @totalDueParam" and totalDueParam is the parameter name.

<asp:EntityDataSource ID="SalesOrderHeaderWithOutAutoParam" runat="server" 
   Where="it.TotalDue < @totalDueParam" 
    Select="it.SalesOrderID, it.TotalDue">
        <asp:ControlParameter ControlID="TotalDueList" 
           Name="totalDueParam" PropertyName="SelectedValue" DbType="Decimal" />

.NET Framework

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Community Additions

© 2015 Microsoft