Search code examples
angularjskendo-uibreeze

Cannot read property 'entityState' of undefined


I have the following metadata:

var entityTypeParent = {
    shortName: 'ParentItemType',
    namespace: 'MyNamespace',
    autoGeneratedKeyType: Identity,
    defaultResourceName: 'ParentItemTypes',

    dataProperties: {
        id: { dataType: DT.Int32, isPartOfKey: true },
        userId: {}
    },

    navigationProperties: {
        user: {
            entityTypeName: 'User',
            isScalar: true,
            associationName: 'ParentItem_User',
            foreignKeyNames: ['userId']
        }
    }
};

var entityTypeUser = {
    shortName: 'User',
    namespace: 'MyNamespace',
    autoGeneratedKeyType: Identity,
    defaultResourceName: 'Users',

    dataProperties: {
        loginName: { dataType: DT.String, isPartOfKey: true },
        displayText: {}
    }
};

In the UI I have a control (Kendo Multi-Select), which is bound to the ParentItemType.user property (AngularJS binding), which allows to select a user from a list (retrieved using breeze-kendo bridge and 'webApiOData' adapter).

Selecting a user results in a "Cannot read property 'entityState' of undefined" exception in setNpValue (https://github.com/Breeze/breeze.js/blob/397b2a02aa2173175c304eb1b37332f1656db6f5/src/a35_defaultPropertyInterceptor.js#L298).

context.newValue is my user entity, which effectively doesn't have an entityAspect (but it contains a __breezeEntity property containting the entityAspect).

Is this an error somewhere in my metadata definition?

Edit: I'm using Breeze 1.5.1


Solution

  • We found the cause of the problem to be the breeze-kendo datasource which removes the entityAspect (I assume to avoid having circular references for the angular binding).