如何使用 Nettiers 从存储过程中获取标量值
我有一个非常简单的存储过程,如下所示:
CREATE PROCEDURE _Visitor_GetVisitorIDByVisitorGUID
(
@VisitorGUID AS UNIQUEIDENTIFIER
)
AS
DECLARE @VisitorID AS bigint
SELECT @VisitorID = VisitorID FROM dbo.Visitor WHERE VisitorGUID = @VisitorGUID
--Here's what I've tried
RETURN @VisitorID 'Returns an IDataReader
SELECT @VisitorID 'Returns an IDataReader
--I've also set it up with a single output
--parameter, but that means I need to pass
--the long in by ref and that's hideous to me
我试图让 nettiers 生成具有此签名的方法:
public long VisitorService.GetVisitorIDByVisitorGUID(GUID visitorGUID);
基本上我希望 Nettiers 调用 ExecuteScalar 而不是 ExecuteReader。我做错了什么?
I have a really simple stored procedure that looks like this:
CREATE PROCEDURE _Visitor_GetVisitorIDByVisitorGUID
(
@VisitorGUID AS UNIQUEIDENTIFIER
)
AS
DECLARE @VisitorID AS bigint
SELECT @VisitorID = VisitorID FROM dbo.Visitor WHERE VisitorGUID = @VisitorGUID
--Here's what I've tried
RETURN @VisitorID 'Returns an IDataReader
SELECT @VisitorID 'Returns an IDataReader
--I've also set it up with a single output
--parameter, but that means I need to pass
--the long in by ref and that's hideous to me
I'm trying to get nettiers to generate a method with this signature:
public long VisitorService.GetVisitorIDByVisitorGUID(GUID visitorGUID);
Basically I want Nettiers to call ExecuteScalar instead of ExecuteReader. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不使用自定义数据访问功能通过 ExecuteScalar 调用存储过程? )
(http://nettiers.com/DataLayer.ashx#Read_Methods:_4 存储过程的主体应如下所示:
或
Why not use the custom data access functionality to call your stored proc with ExecuteScalar? (http://nettiers.com/DataLayer.ashx#Read_Methods:_4)
The body of the stored proc should look like:
or
对于那些想要以编程方式执行此操作的人,上面的示例将不起作用,因为无法使用该方法的任何覆盖来传递必要的参数值。
我发现实现此目的的唯一方法是将 DbCommand 作为单独的参数传递给 ExecuteScalar 方法:
For those wanting to do this programatically, the above example will not work as there is no way to pass the necessary parameter value using any of that method's overrides.
The only way I've found to accomplish this is by passing a DbCommand as a lone argument to the ExecuteScalar method: