Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top