ORM where condition re-designed