我首先在我的一个项目中使用EF 5数据库。
我有一个stored procedure,它根据某些条件返回数据。如果存储过程中的任何条件都是true,则返回类型是相同的。
但是如果non of them是true,则存储过程中的最后一条语句是RETURN。在实体框架中,此存储过程的返回类型映射到complex type。
如果发生上述情况,我将得到以下错误。The data reader is incompatible with the specified 'Context.ComplexType'. A member of the type, 'Id', does not have a corresponding column in the data reader with the same name.
我怎样才能解决这个问题?
发布于 2013-12-03 13:52:31
当条件为false时,您可以返回一个空数据集,而不是允许存储过程落入RETURN:
select * from dbo.Foos where 0 = 1
https://stackoverflow.com/questions/20352700
复制相似问题