Julián Yuste
Julián Yuste

Reputation: 1472

Know why navigation property is empty

Let's suppose that I have order entities that may or may not have order lines( a navigation collection ).

When I click on an order, the order lines are shown.

Is there a way to know if the navigation collection of order lines is empty because there aren't order lines or because they are not in cache ( they were never got from database )?

Upvotes: 0

Views: 101

Answers (2)

Jay Traband
Jay Traband

Reputation: 17052

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

Upvotes: 2

Jay Traband
Jay Traband

Reputation: 17052

It's a good question, but we don't have a great answer yet. We are considering adding some mechanism to breeze to allow you to ask if a given navigation property on a given entity has already been loaded.

But for now, your best bet would be to keep track of this yourself by adding your own property to the entityAspect that keeps track of which navProperties are loaded. You would update this property during the execution of the promise resolution callback after each query. Context as to what properties are involved can be determined by examining the query that has just been executed. ( the query is available within the callback).

I will post back once we have a better answer.

Upvotes: 0

Related Questions