parth1729
parth1729

Reputation: 125

breezejs navigation property with include not working

I have server side code written which is including navigational property for many to many relation ship as shown below.

var result = _contextProvider.Context.ResourceProperty.Include("AssociatedStandardResourceProperty.AssociatedLists").Where(t => t.ResourceId == resId);
        //Return matching resource properties
        return result;

However, when i am trying to retrieve data from breeze datacontext i am getting query execution error as shown below.

var getResourceProperties = function (resourceId, resourcePropertyObservable) {

        var query = EntityQuery.from('GetResourceProperties')
            .withParameters({ resourceId: resourceId })
            .expand("AssociatedStandardResourceProperty.AssociatedLists");

        return manager.executeQuery(query)
            .then(querySucceeded)
            .fail(queryFailed);

        function querySucceeded(data) {
            if (resourcePropertyObservable) {
                resourcePropertyObservable(data.results);
            }
            log('Retrieved listObservable from remote data source',
                data, true);
        }
    };

Query is failing and all data is retreived in log message i have written in queryFailed function.

I have also checked by removing expand at client side and also removing include at server side and then including expand at client side.

Please let me know how i can make it work.

Thanks

Upvotes: 1

Views: 475

Answers (2)

parth1729
parth1729

Reputation: 125

I have observed that problem was due to many to many mapping between two entities . After removing the relationship we are able to retrieve associatedEntities data

Upvotes: 1

Jay Traband
Jay Traband

Reputation: 17052

Just a guess here, but if you are performing the include on the server, then you don't need the expand on the client and vice versa. Your example seems to be doing both. What is the error message that you are getting?

Upvotes: 0

Related Questions