共用方式為


CommandText 項目 (SSDL)

存放結構定義語言 (SSDL) 中的 CommandText 項目是 Function 項目的子項目,可讓您定義資料庫上執行的 SQL 陳述式。 CommandText 項目可讓您加入與資料庫中之預存程序類似的功能,但是您可在儲存模型中定義 CommandText 項目。

CommandText 項目不能有子項目。 CommandText 項目的主體必須是基礎資料庫的有效 SQL 陳述式。

沒有屬性適用於 CommandText 項目。

範例

下列範例顯示 Function 項目包含一個 CommandText 子項目。 透過將 UpdateProductInOrder 函式匯入概念模型來將它公開為 ObjectContext 上的方法。 如需詳細資訊,請見How to: Define Custom Functions in the Storage ModelHow to: Import a Stored Procedure

<Function Name="UpdateProductInOrder" IsComposable="false">
  <CommandText>
    UPDATE Orders
    SET ProductId = @productId
    WHERE OrderId = @orderId;
  </CommandText>
  <Parameter Name="productId"
             Mode="In"
             Type="int"/>
  <Parameter Name="orderId"
             Mode="In"
             Type="int"/>
</Function>

另請參閱

概念

Entity Framework 概觀
SSDL 規格
Function 項目 (SSDL)

其他資源

CSDL、SSDL 和 MSL 規格
ADO.NET Entity Data Model Tools
How to: Add a Defining Query