使用带有最新 PetaPoco 的 SQL Server 2005 和以下代码:
Dim count = New SqlParameter("@Count", System.Data.ParameterDirection.Output)
count.DbType = Data.DbType.Int32
Dim results = db.Query(Of User)(";exec SearchUserPaged @@page=@page, @@maximumRows=@maximumRows, @@ClientID=@ClientID, @@orderBy=@SortExp, @@Count=@Count OUT",
New With {.page = pageEx, .maximumRows = maximumRowIndex, .ClientID = Me.ClientID, .SortExp = sortExpression, .Count = count}).ToList()
'Dim results = db.EDPEntities.Query(Of User)(";exec SearchUserPaged @@page=@0, @@maximumRows=@1, @@ClientID=@2, @@orderBy=@3, @@Count=@4 OUTPUT",
' pageEx, maximumRowIndex, Me.ClientID, sortExpression, count).ToList()
If IsDBNull(count.Value) Then
Me.Count = 0
Else
Me.Count = count.Value
End If
但是输出参数总是返回 0 值。对 PetaPoco 来说很新,所以不确定我是否遗漏了一些非常明显的东西。
这是 Peta 生成的 SQL,它在查询分析器中运行良好:
DECLARE @0 int,@1 int,@2 int,@3 nvarchar(4000),@4 int
SET @0=1
SET @1=25
SET @2=10145
SET @3=NULL
SET @4=2
exec SearchUserPaged @page=@0, @maximumRows=@1, @ClientID=@2, @orderBy=@3, @Count=@4 OUT
SELECT @4
当我SELECT @4
返回正确的值时。