Description
We support projecting entities which own JSON entities, we also support projecting those entities directly accessed from the owner, as well indexing into individual elements.
However, when to-be-projected JSON entity was accessed via some query operation (e.g. filter, paging, etc) we convert the JSON column into query root using OPENJSON/json_each. This makes it so that the entity looks as if it was a normal entity to the materializer.
Normal entities go through different materialization codepath than JSON entities.
- normal entities have all the Include calls preserved and each entity/collection in the include chain is generated separately. JSON only keeps the root level includes at the query level, and the materializer itself generates all the necessary includes.
- JSON entities, specifically collections contain synthesized (key) properties that don't correspond to any column in the database. Materializer for JSON knows to disregard them, but materializer for normal entity tries to extract value from column for every property in the entity.