使用非实体返回类型在实体模型中导入功能 [英] Function Imports in Entity Model with a non-Entity Return Type

查看:113
本文介绍了使用非实体返回类型在实体模型中导入功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



问题是... Visual Studio生成模型中的函数代码代码隐藏,如果且仅当我将返回指定为实体类型。 标量和空返回类型不起作用。当我选择它时,Visual Studio不会生成功能代码。



有没有什么我错过了,还是这个bug? $ b任何工作?





使用Visual Studio 2008 v9.0.30729.1 SP(Service Pack 1)

解决方案

这不是一个bug,因为缺少一个功能。实体框架目前不支持返回标量值的存储过程。我相信这应该是在.NET 4.0中改变。在此期间,您可以使用存储连接执行这样的存储过程,可以通过 CreateDbCommand


I have a stored procedure in my Entity Data Model and added it to the function imports.

Problem is... Visual Studio generates the function code in the model's code-behind if and only if I specify the return to be an entity type. Scalar and null return types do not work. Visual Studio does not generate the function code when I choose them.

Is there something I am missing, or is this a bug?
Any work-arounds?


Using Visual Studio 2008 v9.0.30729.1 SP (Service Pack 1)

解决方案

It's not so much a bug as it is the lack of a feature. The Entity Framework just doesn't support stored procedures returning scalar values right now. I believe this is supposed to change in .NET 4.0. In the meantime, you can execute such a stored procedure by using the store connection, available via CreateDbCommand.

这篇关于使用非实体返回类型在实体模型中导入功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆