Compartilhar via


FunctionImportMapping Element (MSL)

The FunctionImportMapping element in mapping specification language (MSL) defines the mapping between a function import in the conceptual model and a stored procedure or function in the underlying database. Function imports must be declared in the conceptual model and stored procedures must be declared in the storage model. For more information, see FunctionImport Element (CSDL) and Function Element (SSDL).

Note

By default, if a function import returns a conceptual model entity type or complex type, then the names of the columns returned by the underlying stored procedure must exactly match the names of the properties on the conceptual model type. If the column names to not exactly match the property names, the mapping must be defined in a ResultMapping element.

The FunctionImportMapping element can have the following child elements:

Applicable Attributes

The following table describes the attributes that are applicable to the FunctionImportMapping element:

Attribute Name Is Required Value

FunctionImportName

Yes

The name of the function import in the conceptual model that is being mapped.

FunctionName

Yes

The namespace-qualified name of the function in the storage model that is being mapped.

Example

The following example is based on the School model. Consider the following function in the storage model:

<Function Name="GetStudentGrades" Aggregate="false" 
          BuiltIn="false" NiladicFunction="false" 
          IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" 
          Schema="dbo">
  <Parameter Name="StudentID" Type="int" Mode="In" />
</Function>

Also consider this function import in the conceptual model:

<FunctionImport Name="GetStudentGrades" EntitySet="StudentGrades" 
                ReturnType="Collection(SchoolModel.StudentGrade)">
  <Parameter Name="StudentID" Mode="In" Type="Int32" />
</FunctionImport>

The following example show a FunctionImportMapping element used to map the function and function import above to each other:

<FunctionImportMapping FunctionImportName="GetStudentGrades"
                       FunctionName="SchoolModel.Store.GetStudentGrades" />

See Also

Other Resources

CSDL, SSDL, and MSL Specifications
Modeling and Mapping
How to: Import a Stored Procedure