EntityDataSource.CommandParameters 屬性

定義

取得查詢的參數集合。

public:
 property System::Web::UI::WebControls::ParameterCollection ^ CommandParameters { System::Web::UI::WebControls::ParameterCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.ParameterCollection CommandParameters { get; }
[<System.ComponentModel.Browsable(false)>]
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.CommandParameters : System.Web.UI.WebControls.ParameterCollection
Public ReadOnly Property CommandParameters As ParameterCollection

屬性值

ParameterCollection,包含傳遞至查詢命令的參數。

屬性

範例

下列範例提供會傳回 Product 物件的集合的 Entity SQL 命令文字。

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

下列範例會傳回投影的資料行系列:

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

備註

屬性 CommandParameters 是用來存取 ParameterCollection 傳遞至使用 CommandText 屬性指定之明確 Entity SQL 查詢的參數。

適用於