Sdílet prostřednictvím


How to: Map a Function Import to a Complex Type (Entity Data Model Tools)

This topic describes how to use the ADO.NET Entity Data Model Designer (Entity Designer) to map a function import to a complex type.

The process for mapping a function import to a complex type involves two steps:

  1. Create a function import that returns a complex type.

  2. Map the columns that are returned by the function import to the specified complex type.

    NoteNote

    Function imports are based on stored procedures. To map a function import to a complex type, the columns returned by the corresponding stored procedure must match the properties of the complex type in number and must have storage types that are compatible with the property types.

To create a function import that returns a complex type

  1. Do one of the following from the Model Browser:

    • Right-click the Function Imports folder (in the EntityContainer node of the conceptual model information) and then select Add Function Import.

    - OR -

    • Open the Stored Procedures folder (in the storage model information), right-click a stored procedure that does not have a corresponding function import, and then select Add Function Import.

    The Add Function Import dialog box appears.

  2. Fill in the settings for the new function import, as follows:

    • Specify the stored procedure for which you are creating a function import in the Stored Procedure Name field. This field is a drop-down list that displays all the stored procedures in the storage model.

    • Specify the name of the function import in the Function Import Name field.

    • Select Complex as the return type and then specify the specific complex return type by choosing the appropriate type from the drop-down list.

  3. Click OK.

    The function import entry is created in the conceptual model.

To map returned columns to a complex type

  1. Right-click the function import in the Model Browser and select Function Import Mapping.

    The Mapping Details window appears and shows the default mapping for the function import. Arrows indicate the mappings between column values and property values. By default, the column names are assumed to be the same as the complex type's property names. The default column names appear in gray text.

  2. If necessary, change the column names to match the column names that are returned by the stored procedure that corresponds to the function import.

See Also

Tasks

How to: Create and Modify Complex Types (Entity Data Model Tools)
How to: Add a Complex Type Property to an Entity (Entity Data Model Tools)
How to: Refactor Existing Properties into a Complex Type Property (Entity Data Model Tools)

Other Resources

Complex Type Objects (Entity Framework)
How to: Execute a Query Using a Stored Procedure with In and Out Parameters (Entity Framework)