private Expression getParsedOrderByColumn ( final Expression column ) { if ( column instanceof Name ) { final Name columnName = ( Name ) column ; final String environment = columnName . getEnvironment ( ) ; if ( environment != null && ! environment . isEmpty ( ) ) { final Expression parsedColumn = column ( columnName . getName ( ) ) ; inject ( parsedColumn ) ; switch ( column . getOrdering ( ) ) { case "DESC" : parsedColumn . desc ( ) ; break ; default : parsedColumn . asc ( ) ; break ; } return parsedColumn ; } } return column ; }
Helper method which removes the environment parameter from a column when it is used inside an order by statement and in a paginated query . This is needed in order to avoid The multi - part identifier could not be bound error which only happens in SQL Server .