1
votes

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

1
I don't see any problems that stand out in your Metadata, but I also don't see a setNpValue method. Where is this? - PW Kad
Ah setting the navigation property. Got it, thought it was specific to your code - consider adding Breeze version and line number to your question as it may help IdeaBlade or someone to help you. - PW Kad
Cool - here is a jsBin that may help get started debugging or helping others to debug - jsbin.com/rulopuqide/1/edit - you still need to type the Identity as it is throwing an error but may help - PW Kad
Here is a plunker to demonstrate that your metadata definition works fine in pure Angular: plnkr.co/edit/4P5Wzu6OwCpgCdVyigAJ?p=preview. Maybe you can use it as the starting place for a repro of the failure. - Ward

1 Answers

1
votes

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).