I manually created an entity to be used for the result of a stored procedure.
I also created a complex type which is used in that entity to group some fields.
When I map the entity to the columns of the stored procedure result I can also map columns to the fields inside the complex type using the class editor dialog.
However, this does not seem to be taken into account. Only when I do the mapping directly in the complex type definition the call works.
Is this a bug?
BTW: It would be nice if one could overload the entity mapping for each stored procedure call. Some stored procedures may return the same "entity" but using different column names. Currently it seems one has to define one entity per stored procedure with different result column names.
PS: I use Entity Developer v4.7, target: NHibernate.
entity mappings and complex types
Re: entity mappings and complex types
We have reproduced the problem assuming there is a following shema in the database:vatirim wrote:When I map the entity to the columns of the stored procedure result I can also map columns to the fields inside the complex type using the class editor dialog.
However, this does not seem to be taken into account. Only when I do the mapping directly in the complex type definition the call works.
Code: Select all
CREATE TABLE dbo.Dept (
DEPTNO int NOT NULL,
DNAME varchar(14) NULL,
LOC varchar(13) NULL,
PRIMARY KEY (DEPTNO)
)
GO
CREATE PROCEDURE dbo.SelectFromDept
@deptno int
AS
SET NOCOUNT ON;
SELECT * FROM dept
WHERE deptno = @deptno;
GO
And now the method works. The corresponding XML:
Code: Select all
<sql-query name="SelectFromDept" callable="true">
<return class="Dept">
<return-property name="DEPTNO" column="DEPTNO" />
<return-property name="DNAME" column="DNAME" />
<return-property name="LOC" column="LOC" />
</return>
<query-param name="deptno" type="Int32" />exec dbo.SelectFromDept :deptno </sql-query>
Code: Select all
<sql-query name="SelectFromDept" callable="true">
<return class="Dept">
<return-property name="DEPTNO" column="DEPTNO" />
</return>
<query-param name="deptno" type="Int32" />exec dbo.SelectFromDept :deptno</sql-query>
Code: Select all
<sql-query name="SelectFromDept" callable="true">
<return class="Dept">
<return-property name="DEPTNO" column="DEPTNO" />
<return-property name="DNAMEType">
<return-column name="DNAME" />
<return-column name="LOC" />
</return-property>
</return>
<query-param name="deptno" type="Int32" />exec dbo.SelectFromDept :deptno</sql-query>
You can change result mapping of your method in the following way: right click on the method in Model Explorer > Result Mapping Details.vatirim wrote:BTW: It would be nice if one could overload the entity mapping for each stored procedure call. Some stored procedures may return the same "entity" but using different column names. Currently it seems one has to define one entity per stored procedure with different result column names.