问题
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