Handle foreach-compatible classes for entities