Reputation: 67
Consider the code snippet below ... the WebApi controller Metadata method is called both times for executeQuery below ... Why?
Thanks, Travis
var manager = (typeof options.breezeController !== 'undefined') ? options.breezeController : Mosaic.Global.defaultBreezeManager();
var query = breeze.EntityQuery
.from("GetColonies")
//.select("VIVLINE_GUID, VIVLINE_NAME")
.orderBy("VIVLINE_NAME");
manager.executeQuery(query);
manager.executeQuery(query)
.then((data) => {
this.viewModel.items.removeAll;
this.prepData(data.results);
this.viewModel.setSelectedValue(selectedModel);
});
Upvotes: 2
Views: 443
Reputation: 17052
Breeze checks if the metadata exists on the client for a given service before each query. If the metadata is not present then it will ask for it before executing the query.
What I am guessing is happening in your case is that both queries start before either returns metadata. This will cause metadata to be fetched more than once. However, once it does make it down you shouldn't see any further requests.
One suggestion would be to force the loading of metadata before any query, i.e.
manager.fetchMetadata().then(function() {
manager.executeQuery(query1);
manager.executeQuery(query2);
}
Upvotes: 2