OrmLite generated SQL for ORDER BY doesn't include table prefix


Has there been any change regarding the table prefix for order by columns in the recent SS versions (past months)?

For example:
ORDER By CreatedDate
ORDER By FirstTable.CreatedDate

It seems like that in previous versions this prefix was included but now it is missing.

I am using ‘autoquery’ but without declaring IJoin on the type.
I manually join the table using “expression.LeftJoin<FirstTable, OtherTable>”.
Without table prefix I now get ambiguous column errors.


Please always include the implementation when posting so we know exactly what you’re referring to, i.e. in this case please include the custom auto query implementation.

The table prefix should be added when the query includes a table join which will add the prefix for to any queries after. It sounds like your Custom AutoQuery implementation has the query applied before you’ve added the table join so OrmLite wont know to include the table prefix.

You can manually force a Query to include a prefix with:

q.PrefixFieldWithTableName = true;

But again this only applies to filters added after.

Which is the issue, OrmLite doesn’t know to include the table prefix. If the query with the ambiguous column is applied in your custom implementation than adding a table join or setting PrefixFieldWithTableName before applying your custom query will allow it to include the prefix. Otherwise your options are to include the join on the AutoQuery DTO or not use AutoQuery for this instance.

Thank you for your observations. I have solved the issue.

1 Like