Edit

Share via


EntityDataSource.CommandParameters Property

Definition

Gets the parameter collection for the query.

C#
[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.ParameterCollection CommandParameters { get; }

Property Value

A ParameterCollection that contains the parameters that are passed to the query command.

Attributes

Examples

The following example supplies Entity SQL command text that returns a collection of Product objects.

XML
<asp:EntityDataSource ID="ProductDataSource" runat="server"
    CommandText="SELECT value p FROM Products AS p
        WHERE p.ProductID
        BETWEEN @OrderIdMin AND @OrderIdMax"
    ConnectionString="name=AdventureWorksEntities"
    DefaultContainerName="AdventureWorksEntities" >
    <CommandParameters>
        <asp:ControlParameter Name="OrderIdMin"
            ControlID="ProductIdMin" Type="Int32"/>
        <asp:ControlParameter Name="OrderIdMax"
            ControlID="ProductIdMax" Type="Int32" />
    </CommandParameters>
</asp:EntityDataSource>

The following example returns a projected series of columns:

XML
<asp:EntityDataSource ID="ProductDataSource" runat="server"
    CommandText="SELECT p.ProductID, p.ProductName, p.UnitsOnOrder
         FROM Products AS p
         WHERE p.ProductID BETWEEN @OrderIDMin AND @OrderIDMax"
         ContextTypeName="AdventureWorksModel. AdventureWorksEntities">
    <CommandParameters>
        <asp:ControlParameter Name="OrderIDMin"
               ControlID="ProductIDMinTextBox" Type="Int32"/>
        <asp:ControlParameter Name="OrderIDMax"
               ControlID="ProductIDMaxTextBox" Type="Int32" />
    </CommandParameters>
</asp:EntityDataSource>

Remarks

The CommandParameters property is used to access the ParameterCollection of parameters that are passed to an explicit Entity SQL query that is specified using the CommandText property.

Applies to

Product Versions
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1