具有非实体返回类型的实体模型中的函数导入 [英] Function Imports in Entity Model with a non-Entity Return Type

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

问题描述

我的实体数据模型中有一个存储过程,并将其添加到函数导入中.

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

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

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?


使用 Visual Studio 2008 v9.0.30729.1 SP(服务包 1)


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

推荐答案

与其说是错误,不如说是缺少功能.实体框架现在不支持返回标量值的存储过程.我相信这应该在 .NET 4.0 中改变.同时,您可以使用存储连接来执行此类存储过程,该存储连接可通过 CreateDbCommand.

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天全站免登陆