Fix reading array values from associated entities.

Split out conditions into temporary variables as the conditions would be a bit batty otherwise.

Refs #4083