Function 要素 (CSDL)

概念スキーマ定義言語 (CSDL) の Function 要素は、概念モデルで関数を定義または宣言するために使用します。 関数は、DefiningExpression 要素を使用して定義されます。 詳細については、「How to: Define Custom Functions in the Conceptual Model」を参照してください。

A Function element can have the following child elements (in the order listed):

関数の戻り値の型は、ReturnType 要素または ReturnType 属性 (下記参照) のいずれかを使用して指定する必要があります。両方で指定することはできません。 有効な戻り値の型には、EdmSimpleType、エンティティ型、複合型、行型、または参照型 (あるいはこれらの型のいずれかのコレクション) があります。 詳細については、「概念モデルの型」を参照してください。

適用可能な属性

The table below describes the attributes that can be applied to the Function element.

属性名 必須 Value

Name

有効

関数の名前。

ReturnType

いいえ

関数の戻り値の型。

Dd468056.note(ja-jp,VS.100).gif注 :
Function 要素には、任意の数の annotation 属性 (カスタム XML 属性) を適用できます。However, custom attributes may not belong to any XML namespace that is reserved for CSDL.カスタム属性の完全修飾名は一意である必要があります。

次の例では、あるインストラクターが雇用されてからの年数を返す関数の定義に Function 要素を使用しています。

<Function Name="YearsSince" ReturnType="Edm.Int32">
  <Parameter Name="date" Type="Edm.DateTime" />
  <DefiningExpression>
    Year(CurrentDateTime()) - Year(date)
  </DefiningExpression>
</Function>

参照

概念

エンティティ フレームワークの概要
CSDL 仕様
FunctionImport 要素 (CSDL)

その他のリソース

CSDL、SSDL、および MSL 仕様
ADO.NET Entity Data Model Tools
model-defined function (Entity Data Model)