1

我有名为 Contact 和 Address 的表,它们都有“ModifiedDate”列。我已经使用存储过程编写了 CUD 操作。但是,当涉及到需要返回所有联系人及其地址的 SELECT 存储过程时,出现了错误。

System.Data.EntityCommandExecutionException:数据读取器与指定的“AddressBookModel.SelectAllContactsWithAddresses_Result2”不兼容。类型的成员“ModifiedDate1”在数据读取器中没有同名的对应列。

我最终更改了存储过程以返回这些列名的不同别名,更不幸的是,我还需要更改模型中实体的属性以匹配所选列。我在这里写了一篇关于这个的博客文章。我知道我可以为两个实体设置单独的选择 SP(和单独的函数导入),但这只是一种情况,也可能发生在其他情况下,同样的列名称可能会从 SP 中的多个表的复杂查询中返回。有人可以提供任何方向吗?

4

1 回答 1

1

我在此处为 EF 的 MS 论坛发布了相同的问题(对不起,交叉发帖),版主确认这是 EF 中的一个错误,并要求我在 Microsoft Connect 中创建一个错误,错误 ID 是 597376,这里是相同的链接

来自Lingzhi Sun MSFT,版主支持论坛>

Hello,   After some research and test,
> I can repro this issue at my side.  
> It can be a limitation of EF when
> handling stored procedure return
> values.  I would recommend you open a
> ticket at Microsoft Connect to report
> this issue to the product team.   If
> it is convenient, please share us with
> the ticket link here to benefit more
> community members.  
于 2010-09-13T05:57:04.327 回答