breeze fetch meta data if not present

烈酒焚心 提交于 2019-12-10 19:17:41

问题


I have an angular / breeze / webapi app which works great except if I refresh a page which has a EntityQuery to return one entity. It then complains that the metadata is not available as the entityquery does not trigger a metadata fetch, unlike a standard query.

If we have reached the page from a previous angular page which has fired a standard breeze query then the metadata is already there and we have no problem.

So question is, how do I check the metadata exists and trigger the metadata call if it is not already done?

Many thanks for any help you can give me.


回答1:


Try something like this:

function fetchMetadata() {
    var manager = new breeze.EntityManager("api/breeze");
    if (manager.metadataStore.isEmpty()) {
        return manager.fetchMetadata();
    }

    return Q.resolve();
}

function start() {
     fetchMetadata().then(function () {
            // Metadata fetched.
            // Do something here.
     });
}


来源:https://stackoverflow.com/questions/19245790/breeze-fetch-meta-data-if-not-present

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