質問

I have inverseProperty on my JayData entity:

'User': { 'type': 'RavenDBMembership.User', 'inverseProperty': '$$unbound' },

I would really like to be able to use it, but don't now how..

As much as I understand, the '$$unbound' value should load the property with include function and then I should be able to use it simply like this:

entity.User

But instead, it does not even add the 'User' to the structure. When I print entity with AngularJS like this:

{{entity}}

I get the structure of the entity with values, but User property is not there!

So.. Any samples or ideas how to use 'inverseProperty': '$$unbound' in JayData?

役に立ちましたか?

解決

So I figured out what was the problem. When the entity model says

'inverseProperty': '$$unbound'

In order to reach those properties, we have to say (User in my case)

context.EntitySet.include('User').toArray(handler);

So the magic keyword here is include('Property_name')

Then we can reach entity.User thingy.

My mistake was to think JayData include automatically.

他のヒント

Sorry for Answering but I cannot Comment...

Are you sure your metadata actually exposes all entities?

I stumbled accross this the other day on GitHub

just a thought...

EDIT:

Actually I was curious so I went to see the sources. in this file (line 364) it says:

 if (memDef.inverseProperty === '$$unbound') {
    //member definition is navigation but not back reference

It seems like your navigation property is not setup for referencing his parent.

Consider the following:

 $data.Entity.extend('Entities.User', {
   'IdPerson': { 'key': true, 'type': 'Edm.Guid', 'nullable': false, 'computed': true },
   'Login': { 'type': 'Edm.String', 'nullable': false, 'required': true, 'maxLength': 20 },
   'Password': { 'type': 'Edm.String', 'nullable': false, 'required': true, 'maxLength': 36 },              
   'Role': { 'type': 'Entities.Role', 'inverseProperty': 'User' }
        }); 

 $data.Entity.extend('Entities.Role', {
   'IdRole': { 'key': true, 'type': 'Edm.Guid', 'nullable': false, 'computed': true },
   'User': { 'type': 'Array', 'elementType': 'Entities.User', 'inverseProperty': 'Role' }
    });

this is actually part of one of my working models, I tried putting '$$unbound' in inverse property and it reproduced your bug.

You should make sure your underlying data model has the proper foreign keys and multiplicity configured. this is in fact what 'inverseProperty' is used for.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top