Function Imports in Entity Model with a non-Entity Return Type(具有非实体返回类型的实体模型中的函数导入)
问题描述
我的实体数据模型中有一个存储过程,并将其添加到函数导入中.
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.
这篇关于具有非实体返回类型的实体模型中的函数导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:具有非实体返回类型的实体模型中的函数导入
基础教程推荐
- 如果条件可以为空 2022-01-01
- 将数据集转换为列表 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
