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)

public bool AutoGenerateWhereClause { get; set; }
<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.

Implements

IDynamicDataSource.AutoGenerateWhereClause

ExceptionCondition
InvalidOperationException

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

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 assigned to the WhereParameters property. This eliminates the need to explicitly assign a WHERE clause to the Where property. The construction of the WHERE clause from the WhereParameters property requires that the Name property of each parameter in the collection identifies a single property of the item returned from the query.

Null values are allowed for the values of the parameters supplied to the WhereParameters property when the AutoGenerateWhereClause property is set to true; when this occurs, the WHERE clause is omitted from the query.

The following example assumes that a check box sets the online order flag:

<asp:EntityDataSource ID="SalesOrderHeader" runat="server" 
    ConnectionString="name=AdventureWorksEntities" 
    DefaultContainerName="AdventureWorksEntities" EnableDelete="True" 
    EnableInsert="True" EnableUpdate="True" EntitySetName="SalesOrderHeader" 
    EntityTypeFilter="" Select="" AutoGenerateWhereClause="True">
    <WhereParameters>
        <asp:ControlParameter ControlID="onlineOrder" DefaultValue="true" 
            Name="OnlineOrderFlag" PropertyName="Text" DbType="Boolean" />
    </WhereParameters>
</asp:EntityDataSource>

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

Community Additions

ADD
Show:
© 2014 Microsoft