ef存储过程映射结果类型问题 [英] ef stored procedure mapping result type problem
问题描述
我有一个存储过程可以做到这一点,例如
Hi,
I have a stored procedure that does this for example
select prop1, prop2 from table
实体框架我已映射此sp以返回如下所示的复杂类型
In entity framework i have mapped this sp to return a complex type like the following
class sp_result
{
public string prop1 { get; set;}
public string prop2 { get; set;}
public string prop3 { get; set;}
}
问题是当我在EF中调用映射的sp时出现异常:
数据阅读器与指定的'prop3'不兼容。类型为prop3的成员在数据读取器中没有相应的列具有相同的名称。
问题是可以忽略丢失的p3属性或者我必须将其作为虚拟数据返回,但是我不需要它只是为了满足EF?
The problem is that i get an exception when i call the mapped sp in EF:
The data reader is incompatible with the specified 'prop3'. A member of the type, 'prop3', does not have a corresponding column in the data reader with the same name.
The question is that it is possible to ignore the missing p3 property or I have to return it as dummy data, althout i don't need it just to satisfy EF?
推荐答案
检查下面提到的链接。可以帮到你。
EF 6:
存储过程映射
EF 4:
实体框架中的存储过程
Check below mentioned links.May be helped to you.
EF 6 :
Stored Procedure Mapping
EF 4 :
Stored Procedures in the Entity Framework
这篇关于ef存储过程映射结果类型问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!