3
votes

Given an entity with a navigation property, is there a way to tell if the empty navigation property is because the child entities have never been loaded, as opposed to the collection having been loaded and just being empty?

eg: I load a page with a list of entity A. Each entity A has a navigation property being a collection of entity B. I don't need to load the navigation property for the list as it might be a large number of child entities so I don't choose to expand the navigation property. However, I want to then show a 'detail' page regarding a single entity A, where I DO want to show the list of entity B. When loading that page, I can use fetchByEntityKey to get the original entity A from the cache, but that cached entity does not include the navigation property collection. Therefore the page won't show the child properties. Is there a way to tell that the navigation property was never loaded, as opposed to the collection just being empty, so I can choose whether to refresh the navigation property with loadNavigationProperty or some other query?

2
You can use the isPartial flag to see if the entity has been fully loaded or not. Is this what you are looking for? Check here stackoverflow.com/questions/16301734/breeze-ispartialPW Kad
The isPartial flag is a custom property added by a custom constructor. I could possibly add something like that but then I would need to find a way to attach a different constructor to the results of different queries. Don't think this sounds like a good idea.Adam
That's not entirely true - if your constructor sets isPartial to false but when you perform your query you set it to true ir false depending on whether you have fully loaded it it should handle your situation. In your logic there is another flaw- if you create an object of type B and then load A you have q false positive that A's Bs are loaded - which would be known if you used is partialPW Kad

2 Answers

3
votes

As of Breeze 1.4.16 two new methods have been added: EntityAspect.isNavigationPropertyLoaded and EntityAspect.markNavigationPropertyLoaded. These are both documented in the breeze api docs. The specific method that you are looking for is documented here:

http://www.breezejs.com/sites/all/apidocs/classes/EntityAspect.html#method_isNavigationPropertyLoaded

0
votes

It's a good question! This is on our list as a needed feature and it should get into the product within the next release or two.