2.1.15 FunctionImport

FunctionImport element is used to import stored procedures or functions that are defined in the Store Schema Model into Entity Data Model (EDM).

The following is an example of the FunctionImport element.

 <FunctionImport Name="annualCustomerSales" EntitySet="result_annualCustomerSalesSet" ReturnType="Collection(Self.result_annualCustomerSales)">
   <Parameter Name="fiscalyear" Mode="In" Type="String" />
 </FunctionImport>

The following rules apply to the FunctionImport element:

  • FunctionImport MUST have a Name attribute defined. Name attribute is of type SimpleIdentifier.

  • FunctionImport can define a ReturnType as an attribute.

  • In CSDL 3.0, the ReturnType can be defined as either an attribute or a child element, but not both.

  • If defined in CSDL 1.1, CSDL 2.0, and CSDL 3.0, the type of ReturnType MUST be a scalar type, EntityType, or ComplexType that is in scope or a collection of one of these in-scope types. In CSDL 1.0, the ReturnType is collection of either scalar type or EntityType.

  • Types that are in scope for a FunctionImport include all scalar types, EntityTypes, and ComplexTypes that are defined in the declaring SchemaNamespace or in schemas that are in scope of the declaring Schema.

  • If the return type of FunctionImport is a collection of entities, the EntitySet attribute is defined.

  • If the return type of FunctionImport is of ComplexType or scalar type, the EntitySet attribute cannot be defined.

  • FunctionImport can contain any number of AnnotationAttribute attributes. The full names of the AnnotationAttribute attributes cannot collide.

  • The FunctionImport element can contain a maximum of one Documentation element.

  • FunctionImport can have zero or more Parameter elements.

  • Parameter element names inside a FunctionImport cannot collide.

  • FunctionImport can have an IsSideEffecting attribute defined. Possible values are "true" and "false". If the IsSideEffecting attribute is omitted, the value of the IsSideEffecting attribute defaults to "true".

  • FunctionImport can have an IsBindable attribute defined. Possible values are "true" and "false". If the IsBindable attribute is omitted, the value of the IsBindable attribute is assumed to be "false".

  • When IsBindable is set to "true", FunctionImport MUST have at least one Parameter element defined.

  • FunctionImport can have an IsComposable attribute defined. Possible values are "true" and "false". If the IsComposable attribute is omitted, the value of the IsComposable attribute is assumed to be "false".

  • FunctionImport cannot have IsComposable set to "true" if IsSideEffecting is set to "true".

  • In CSDL 2.0 and CSDL 3.0, FunctionImport can contain any number of AnnotationElement elements.

  • In CSDL 3.0, FunctionImport can have an EntitySetPath attribute defined. EntitySetPath defines the EntitySet that contains the entities that are returned by the FunctionImport when that EntitySet is dependent on one of the FunctionImport parameters. For example, the entities returned from a FunctionImport can be dependent on the entity set that is passed to the FunctionImport as a parameter. In this case, a static EntitySet is not sufficient, and an EntitySetPath is used. EntitySetPath is composed of segments that are separated by a forward slash. The first segment refers to a FunctionImport parameter. Each remaining segment represents either navigation, in which case the segment is a SimpleIdentifier, or a type cast, in which case the segment is a QualifiedName.

  • In CSDL 3.0, FunctionImport can contain any number of ValueAnnotation elements.

  • Child elements of FunctionImport are to appear in this sequence: Documentation (if present), ReturnType, Parameter, AnnotationElement.

Graphic representation in table format of the rules that apply to the FunctionImport element.

All child elements are to appear in the order indicated.