SubSonic:检索存储过程 OUT 参数的值
我喜欢你的工具。 我已经经常使用它,但就在今天我遇到了一个问题...
我编写了一个存储过程,通过 OUT 参数返回一些值,但 SubSonic 似乎没有生成存储过程方法的输出参数。 例如,对于像这样的 SPI:
CREATE PROC dbo.MyProc @param1 int, @param2 int out, @param3 varchar(150) out
它会生成签名
SPs.MyProc(int? param1, int? param2, string param3
我希望它生成这个
SPs.MyProc(int? param1, out int? param2, out string param3)好吧,考虑到该方法实际上只是配置 SP 而不是实际执行它,我希望 Subsonic 生成这个
SPs.MyProc(int? param1, ref int? param2, ref string param3)
你们如何解决这个问题? Subsonic 中已经有类似的东西了,只是我错过了?
I love your tool. I have been using it a lot, but just today I ran into a problem...
I wrote a stored procedure that returns some values via OUT parameters, but SubSonic does not seem to generate the out parametes of the stored procedure method. For example, for SPI like this:
CREATE PROC dbo.MyProc @param1 int, @param2 int out, @param3 varchar(150) out
It generates signature
SPs.MyProc(int? param1, int? param2, string param3
I would expect it to generate this
SPs.MyProc(int? param1, out int? param2, out string param3)
Well, considering that the method actually just configures the SP and does not actually execute it, I woiuld expect Subsonic to generate this
SPs.MyProc(int? param1, ref int? param2, ref string param3)
How do you guys solve this problem? Is there something like that in Subsonic already and I just missed it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看来 OutputParameters 的使用不能与 .GetReader() 结合使用,而只能与 .Execute() 结合使用。
我无法结合使用 OUTPUT 参数从数据库中检索记录。
例如,我有一个存储过程,它从数据库返回新闻通讯列表,但我想使用 SQL Server 2005 的分页功能。因此,我提供了 pageSize 和我想要查看的实际页面。 在同一过程中,我想计算可用页面的数量并使用输出变量返回该页面。
我无法让它发挥作用。 OutputParameters 列表中有 1 项,但值始终为 NULL。
It seems that the usage of OutputParameters doesn't work in combination with .GetReader(), but only with .Execute().
I'm unable to retrieve records from the database in combination with the usage of OUTPUT parameters.
For example, I have a storedprocedure that returns a list of newsletters from the database, but I want to use the paging functionality of SQL Server 2005. So I provide the pageSize and actual page I want to see. In the same procedure I want to count the amount of pages that are available and return that using an output variable.
I don't get it to work. The list with OutputParameters has 1 item in it, but the value is always NULL.
您必须将 SP 实例化为对象然后运行它 - 然后它会将 OUTPUT 参数作为属性传递给您。
You have to instantiate the SP as an object then run it - it will then hand you the OUTPUT param as a property.
来源
您可以使用 StoredProcedure.OutputValues 访问 SubSonic 中 SP 的 OuPut 参数;
以下是访问 SP 的 OutPut 参数的代码块,这里我起诉了 SP“UspTestOutPut”:
SOURCE
You can acess OuPut parametes of SP in SubSonic using StoredProcedure.OutputValues;
Folowing is the chunk of code to access OutPut parameters of SP, here i have sued SP “UspTestOutPut”:
我正在使用 subsonic 和 Sqlserver 2005 服务器。 对于分页功能,我将当前页面和页面大小作为输入参数传递。 为了获取记录总数,我使用 @TotalCount int OUTPUT 参数变量。
在 StoresPrecedure 中,我这样使用:
Select * from TestTable where PageSize=@PageSize and CurrentPage = @CurrentPage —— 它获取当前页面记录。
设置 @Query ="Insert ....."
EXEC sp_executesql @Query
受插入语句影响的记录总数
SET @TotalCount = @@Rowcount --我的 C#.net 亚音速类文件中 ,我使用 GetDataSet() 来获取结果DataSet和OutputValues[0]以从输出参数中获取值。
I'm using subsonic and Sqlserver 2005 server. for the paging functionality, i pass the currentpage and pagesize as input parameters. To get the total number of records, i use @TotalCount int OUTPUT parameter variable.
in the StoresPrecedure, i use like this:
Select * from TestTable where PageSize=@PageSize and CurrentPage = @CurrentPage -- it gets the current page records.
Set @Query ="Insert ....."
EXEC sp_executesql @Query
SET @TotalCount = @@Rowcount -- total number of records affected by insert statement
in my C#.net - subsonic class file, i use, GetDataSet() to get the result DataSet and OutputValues[0] to get the value from the output parameter.