2011-06-05 87 views

回答

1

Projection.Count希望你傳遞你想上即

Projection.Count("propertyName") 

計數其transalates在SQL

select Count(this.whateverNhibernateConvention) from table as this 

以下內容,其中爲Projection.RowCount你不需要的屬性通過任何轉化爲的東西

select Count(1) from table as this 

我想我期待上述情況

+0

在第二個表達式中,不應該是'select Count(*)'?我不知道'select count(1)'結果是什麼,但我認爲(至少在Transact-SQL中)它應該是「count(*)」來匹配你的第二個解釋嗎? – johngrinder 2011-06-05 15:28:33

+0

Nope select count(1)非常好.. COUNT函數不需要像使用COUNT(*)語法時那樣從表中檢索所有字段。它只會檢索符合條件的每條記錄的數值1。希望有道理 – Baz1nga 2011-06-05 17:42:21

+0

請注意查詢成本是相同的,它不會影響你使用什麼。Count(1)是計數(*)僞裝 – Baz1nga 2011-06-05 17:43:42