Udostępnij za pośrednictwem


ReturnType Element (CSDL)

The ReturnType element in conceptual schema definition language (CSDL) specifies the return type for a function that is defined in a Function element. A function return type can also be specified with a ReturnType attribute. For more information, see Function Element (CSDL).

Return types can be any EdmSimpleType, entity type, complex type, row type, ref type, or a collection of one of these types. For more information, see Conceptual Model Types (CSDL).

The return type of a function can be specified with either the Type attribute of the ReturnType element, or with one of the following child elements:

Note

A model will not validate if you specify a function return type with both the Type attribute of the ReturnType element and one of the child elements.

Applicable Attributes

The following table describes the attributes that can be applied to the ReturnType element.

Attribute Name Is Required Value

ReturnType

No

The type returned by the function.

Note

Any number of annotation attributes (custom XML attributes) may be applied to the ReturnType 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.

Example

The following example uses a Function element to define a function that returns the number of years a book has been in print. Note that the return type is specified by the Type attribute of a ReturnType element.

<Function Name="GetYearsInPrint">
  <ReturnType Type=="Edm.Int32">
  <Parameter Name="book" Type="BooksModel.Book" />
  <DefiningExpression>
   Year(CurrentDateTime()) - Year(cast(book.PublishedDate as DateTime))
  </DefiningExpression>
 </Function>

See Also

Concepts

Property Element (CSDL)
DefiningExpression Element (CSDL)
ReturnType Element (CSDL)