Fix TemplateExpression equals contract
Improve entity projection handling for native queries #620