Pic*_*ght 17 entity-framework-4
我使用我的存储过程更新了我的模型,在模型浏览器中我可以看到它也有一个Function导入.
如果不存在,我的SP会插入一条记录并返回1,否则返回0,我认为非常简单.
SP
CREATE PROCEDURE [dbo].[User_UpdateMessage]
(
@UserId int = 0,
@UserId2 int = 0,
@Success bit = 0 OUTPUT
)
AS
BEGIN
SET NOCOUNT ON;
IF NOT EXISTS ( SELECT [UserIdFrom] FROM [dbo].[MessageUpdate] WHERE [UserIdFrom] = @UserId AND [UserIdTo] = @UserId2 )
BEGIN
INSERT INTO [dbo].[MessageUpdate] ([UserIdFrom], [UserIdTo])
VALUES (@UserId, @UserId2)
SELECT @Success = 1;
END
ELSE
SELECT @Success = 0;
END
Run Code Online (Sandbox Code Playgroud)
在我的代码中,我打电话给SP:
// Output Parameter
System.Data.Objects.ObjectParameter paramSuccess1 =
new System.Data.Objects.ObjectParameter("Success", typeof(byte));
_Entity.User_UpdateMessage(id, userId, paramSuccess1);
Run Code Online (Sandbox Code Playgroud)
执行SP时失败,出现以下错误:
商店数据提供程序返回的数据读取器没有足够的列用于请求的查询
[更新]
当我写这篇文章时,我解决了这个问题.在模型设计器中,返回类型应该是none,我让它返回Byte.
这个问题的答案可能是进一步的改进或变化.
ste*_*ndo 14
我也有同样的问题,将返回类型更改为NONE而不是int32.谢谢节省了我几个小时的调试
| 归档时间: |
|
| 查看次数: |
14386 次 |
| 最近记录: |