Fix EntityContext operations on collections.

There were a few cases where EntityContext would hit a fatal error when dealing with collections/arrays. This fixes that and also introduces a minor optimization for array properties.