Breeze - How to Load Navigation property from cache

纵饮孤独 提交于 2019-12-05 19:24:38

You can use the EntityQuery.fromEntityNavigation method to construct a query based on an entity and a navigationProperty . From there you can execute the resulting query locally, via the EntityManager.executeQueryLocally method. So in your example once you have a 'project' entity you can do the following.

var messagesNavProp = project.entityType.getProperty("messages");
var query = EntityQuery.fromEntityNavigation(project, messagesNavProp);
var messages = myEntityManager.executeQueryLocally(query);

You can also make use of the the EntityQuery.using method to toggle a query between remote and local execution, like this:

query = query.using(FetchStrategy.FromLocalCache);

vs

query = query.using(FetchStrategy.FromServer);    

please take a look here: http://www.breezejs.com/sites/all/apidocs/classes/EntityManager.html as you can see fetchEntityByKey ( typeName keyValues checkLocalCacheFirst ) also have a third optional param that you can use to tell breeze to first check the manager cache for that entity

hope this helps

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!