Fixing query build in Orm