0
votes

If I perform the following breeze query:

var foos = manager.executeQueryLocally(
    breeze.EntityQuery.from("foos")
          .withParameters({bar:"xyz"})
);
console.log(foos[0].myCollectionNavigationProperty);

the returned myCollectionNavigationProperty seems to be a javascript array with a length of 0 if either:

  1. The collection navigation property truly has no matching elements on the server database

  2. The collection navigation property has not previously been queried on the server and is therefore not in the local cache

Ideally, case 2 would result in a null (or undefined) value for myCollectionNavigationProperty

Obviously in case 2 above, I need to send a query to the server to get the related entities, however if the appropriate query has already been sent, and the array is empty because there are truly no matching elements - I do not need to requery the server.

Is there a way with breeze to tell if an associated collection of entities is empty because it has not yet been queried on the server? Thank you.

1

1 Answers

0
votes

Don't all jump in at once! I stumbled across this (I was looking at properties on the entityAspect, but not looking closely enough at methods).

The entityAspect property has an isNavigationPropertyLoaded method, which takes the property name as a string. It also has a loadNavigationProperty method (identical argument) which returns a promise.