-
Notifications
You must be signed in to change notification settings - Fork 18
Description
breeze-client/src/mapping-context.ts
Line 308 in 8326490
| em._attachEntityCore(targetEntity, EntityState.Unchanged, mergeStrategy); |
When an object referencing itself is returned from the EFCore server, it doesn't correctly use $ref (IMO EFCore bug) and the two objects are in the JSON instead of one, e.g. { 'id': 1, 'ownerId': 1, 'owner': { 'id': 1, 'ownerId': 1, 'owner': null, ... }, ... }. The mapping in Breeze results in entityAspect to have state 'Detached' and an empty entityManager. This is because the reference object is processed first (due to recursion in visitAndMerge) and stored. It is then correctly recognized inside _attachEntityCore and returned, but the return value is disregarded, leaving the original entity being mapped detached.
Suggested fix: replace the line with targetEntity = em._attachEntityCore(targetEntity, EntityState.Unchanged, mergeStrategy);
This would be in accord with EntityManager:
breeze-client/src/entity-manager.ts
Line 797 in 8326490
| attachedEntity = this._attachEntityCore(entity, esSymbol, msSymbol); |