Add a LIMIT clause to the given SQL SELECT
Namespace:
NHibernate.DialectAssembly: NHibernate (in NHibernate.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Overrides Function GetLimitString ( _ querySqlString As SqlString, _ offset As Integer, _ last As Integer _ ) As SqlString |
C# |
---|
public override SqlString GetLimitString( SqlString querySqlString, int offset, int last ) |
Visual C++ |
---|
public: virtual SqlString^ GetLimitString( SqlString^ querySqlString, int offset, int last ) override |
JavaScript |
---|
function getLimitString(querySqlString, offset, last); |
Parameters
- querySqlString
- Type: NHibernate.SqlCommand..::.SqlString
The SqlString to base the limit query off of.
- offset
- Type: System..::.Int32
Offset of the first row to be returned by the query (zero-based)
- last
- Type: System..::.Int32
Maximum number of rows to be returned by the query
Return Value
A new SqlString with the LIMIT clause applied.
Remarks
The LIMIT SQL will look like
Note that we need to add explicitly specify the columns, because we need to be able to use them
in a paged subselect. NH-1155
![]() | |
---|---|
SELECT TOP last (columns) FROM ( SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_1__ {sort direction 1} [, __hibernate_sort_expr_2__ {sort direction 2}, ...]) as row, (query.columns) FROM ( {original select query part}, {sort field 1} as __hibernate_sort_expr_1__ [, {sort field 2} as __hibernate_sort_expr_2__, ...] {remainder of original query minus the order by clause} ) query ) page WHERE page.row > offset |