Skip to content

Commit e14a685

Browse files
committed
NH-3428 Added a check to see if the sortexpression is the alias
1 parent db55ffc commit e14a685

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/NHibernate/Dialect/MsSql2005DialectQueryPager.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ private static void AppendSortExpressionsForDistinct(Dictionary<SqlString, SqlSt
201201
result.Add("q_.");
202202
result.Add(columnToAlias[sortExpression]);
203203
}
204+
else if (columnToAlias.ContainsValue(sortExpression)) // When a distinct query is paged the sortexpressions could already be aliased.
205+
{
206+
result.Add("q_.");
207+
result.Add(sortExpression);
208+
}
204209
else
205210
{
206211
throw new HibernateException(

0 commit comments

Comments
 (0)