2

Closed

Add support for custom result mapping

description

In EF 6.1.1 it is possible to define custom mappings between columns returned by a store function and properties of entity/complex type the result of store function is mapped to (https://entityframework.codeplex.com/workitem/2192). The convention currently allows only 1:1 mapping (i.e. the name of the column has to match the name of the property). Consider adding support for custom result mapping where the user can specify which column will be mapped to which property.

comments

moozzyk wrote Jul 23, 2014 at 6:27 AM

As per Angel's comment to the post - further changes to EF codebase are required to support custom result mapping:

_Yes, those commits were a prerequisite for custom mappings, thanks for authoring them.

The code missing is for NonComposable functions with ResultMappings, that creates a new EdmItemCollection when StorageMappingItemCollection is null.

Look at the changes you made in file Core/Mapping/FunctionImportMappingNonComposable.cs in commit b4cb2b1. The consturctor of FunctionImportMappingNonComposable crashes if resultMappings.Any() is true.

I’m currently using the code from my fork in production and it works great with custom mappings, but we do not use non composable functions.
_