0
我在嘗試使用setFirstResult時遇到Nhibernate版本3.3.3的問題。Nhibernate setFirstResult
IQuery q = session.CreateQuery("Select a from SelectionAssignment a ")
.SetFirstResult(1)
.SetMaxResults(10);
var assignments = q.List<SelectionAssignment>();
上述吐出這樣的SQL:
SELECT TOP (10) asId30_
, asHostId30_
, asDescript3_30_
, asIsChase30_
, asPosition30_
, asGoalTime30_
, asRoute30_
, asActiveta8_30_
, asPassAssi9_30_
, asSummary10_30_
, asOverrid11_30_
, asDeliver12_30_
, asDirectLoad30_
, asAllowDe14_30_
, asVehicle15_30_
, asCustomerId30_
, asTotalWe17_30_
, asTotalItems30_
, asSingleSKU30_
, asSingleB20_30_
, asCreated21_30_
, asStartDate30_
, asEndDate30_
, asPriority30_
, asIsDeleted30_
, asDeleted26_30_
, asDeleted27_30_ FROM
(
select selectiona0_.Id as Id30_
, selectiona0_.HostId as HostId30_
, selectiona0_.Description as Descript3_30_
, selectiona0_.IsChase as IsChase30_
, selectiona0_.Position as Position30_
, selectiona0_.GoalTime as GoalTime30_
, selectiona0_.Route as Route30_
, selectiona0_.ActivetargetContainer as Activeta8_30_
, selectiona0_.PassAssignment as PassAssi9_30_
, selectiona0_.SummaryPromptType as Summary10_30_
, selectiona0_.OverridePrompt as Overrid11_30_
, selectiona0_.DeliveryLocationId as Deliver12_30_
, selectiona0_.DirectLoad as DirectLoad30_
, selectiona0_.AllowDeliverLocationOverride as AllowDe14_30_
, selectiona0_.VehicleLicense as Vehicle15_30_
, selectiona0_.CustomerId as CustomerId30_
, selectiona0_.TotalWeight as TotalWe17_30_
, selectiona0_.TotalItems as TotalItems30_
, selectiona0_.SingleSKU as SingleSKU30_
, selectiona0_.SingleBatch as SingleB20_30_
, selectiona0_.CreatedDate as Created21_30_
, selectiona0_.StartDate as StartDate30_
, selectiona0_.EndDate as EndDate30_
, selectiona0_.Priority as Priority30_
, selectiona0_.IsDeleted as IsDeleted30_
, selectiona0_.DeletedDate as Deleted26_30_
, selectiona0_.DeletedUser as Deleted27_30_
, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row
from SelectionAssignment selectiona0_ where (selectiona0_.IsDeleted=0)
) as query
WHERE query.__hibernate_sort_row > 0
ORDER BY query.__hibernate_sort_row
而如果我設定的參數進行.SetFirstResult(0),它工作正常。
有誰能告訴我爲什麼?或者我該如何解決這個問題?
編輯:道歉,我收到無效的列名稱的錯誤消息「asId30「asHostId30」等列名是標識,主機標識等
我想這可能是一個愚蠢的評論,但你能指出問題在哪裏? – jbl
很抱歉編輯解釋 – user2248441
可能是一個方言問題,但首先要添加的是您的select語句中的ORDER BY。沒有它,First和Max是沒有意義的。 – jbl