Function Element (CSDL)

The Function element in conceptual schema definition language (CSDL) is used to define or declare functions in the conceptual model. A function is defined by using a DefiningExpression element. For more information, see How to: Define Custom Functions in the Conceptual Model.

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

A return type for a function must be specified with either the ReturnType element or the ReturnType attribute (see below), but not both. The possible return types are any EdmSimpleType, entity type, complex type, row type, or ref type (or a collection of one of these types). For more information, see Conceptual Model Types (CSDL).

Applicable Attributes

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

Attribute Name Is Required Value



The name of the function.



The type returned by the function.


Any number of annotation attributes (custom XML attributes) may be applied to the Function element. However, custom attributes may not belong to any XML namespace that is reserved for CSDL. The fully-qualified names for any two custom attributes cannot be the same.


The following example uses a Function element to define a function that returns the number of years since an instructor was hired.

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

See Also


Entity Framework Overview
CSDL Specification
FunctionImport Element (CSDL)

Other Resources

CSDL, SSDL, and MSL Specifications
ADO.NET Entity Data Model Tools
model-defined function (Entity Data Model)