Bri*_*ins 3 stored-procedures output-parameter petapoco
我正在尝试使用PetaPoco设置输出参数.我发现有人在线使用这个样本:
var ctx = new CustomDBDatabase();
var total = new SqlParameter("Total", System.Data.SqlDbType.Int);
total.Direction = System.Data.ParameterDirection.Output;
var results = ctx.Query<DBEntity>("exec GetDBEntities @StartIndex, @MaxIndex, @TotalCount = @Total out",
id, start, max, total);
int totalCount = (int)total.Value;
Run Code Online (Sandbox Code Playgroud)
但是,total.value返回null,即使我直接针对SQL Server运行此语句,它也会返回3.这是否与PetaPoco正确设置?是否支持输出参数?
谢谢.
这是支持的.但无论如何,你目前的语法是错误的.
var ctx = new CustomDBDatabase();
var total = new SqlParameter("TotalCount", System.Data.SqlDbType.Int);
total.Direction = System.Data.ParameterDirection.Output;
var results = ctx.Query<DBEntity>("exec GetDBEntities @StartIndex, @MaxIndex, @TotalCount OUTPUT", new { StartIndex = start, MaxIndex = max, TotalCount = total});
int totalCount = (int)total.Value;
Run Code Online (Sandbox Code Playgroud)
这样的事情应该可行.不太确定sql语法,但这应该让你顺利.
| 归档时间: |
|
| 查看次数: |
5559 次 |
| 最近记录: |