EntityDataSource.AutoGenerateWhereClause Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a value that indicates whether the EntityDataSource control dynamically creates a WHERE clause based on values defined in the WhereParameters collection.
public:
property bool AutoGenerateWhereClause { bool get(); void set(bool value); };
public bool AutoGenerateWhereClause { get; set; }
member this.AutoGenerateWhereClause : bool with get, set
Public Property AutoGenerateWhereClause As Boolean
Property Value
true
if the EntityDataSource control creates the WHERE clause; otherwise, false
. The default value is false
.
Implements
Exceptions
When the AutoGenerateWhereClause property is set to true
and the Where property is not null.
Examples
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"
ConnectionString="name=AdventureWorksEntities"
DefaultContainerName="AdventureWorksEntities"
EntitySetName="SalesOrderHeaders"
Select="it.SalesOrderID, it.TotalDue"
AutoGenerateWhereClause="True">
<WhereParameters>
<asp:ControlParameter ControlID="TotalDueList"
Name="TotalDue" PropertyName="SelectedValue" DbType="Decimal" />
</WhereParameters>
</asp:EntityDataSource>
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"
ConnectionString="name=AdventureWorksEntities"
DefaultContainerName="AdventureWorksEntities"
EntitySetName="SalesOrderHeaders"
Where="it.TotalDue < @totalDueParam"
Select="it.SalesOrderID, it.TotalDue">
<WhereParameters>
<asp:ControlParameter ControlID="TotalDueList"
Name="totalDueParam" PropertyName="SelectedValue" DbType="Decimal" />
</WhereParameters>
</asp:EntityDataSource>
Remarks
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.
Applies to
.NET