如何从以下查询中获取总行数和记录?
Contracts cont = db.contracts.SqlQuery("SELECT TOP (20) *
FROM (SELECT
ROW_NUMBER() OVER (ORDER BY dbo.Contracts.expDate desc) As RowID,
dbo.Contracts.*,
TotalRows=COUNT(*) OVER()
FROM dbo.Contracts
Where dbo.Contracts.cancelled = 1) as temp
WHERE temp.RowID >" + 20).ToList();
我正在获取记录,但不知道如何获取总行数。任何机构都可以建议从上述查询中获取总行数和记录的最佳方法吗?