Reputation: 1696
In my client solution there is a need to do a partial refresh from the server. Is it possible to clear all the defined constructors and all the cache?
even tried
dataService = new breeze.DataService(breezeDataServiceSettings),
ms = new breeze.MetadataStore();
manager = new breeze.EntityManager({ dataService: dataService , metadataStore: ms});
on every refresh
i found that i need to clear yhe entityType in the prototype
var ctor = ctorFactory.createCtor(allTypes[type].shortName),
store = manager.metadataStore;
ctor.prototype.entityType = undefined;
store.registerEntityTypeCtor(allTypes[type].shortName, ctor);
Upvotes: 1
Views: 989
Reputation: 26406
give this a try:
var controllerName = '...',
serviceUrl = 'https://..../' + controllerName,
metadataUrl = serviceUrl + '/Metadata',
entityManager = new breeze.EntityManager();
$.ajax({ url: metadataUrl, type: 'GET', dataType: 'text' })
.then(metadataJson => {
entityManager.metadataStore.importMetadata(metadataJson);
entityManager.metadataStore.addDataService(new breeze.DataService({ serviceName: serviceUrl }));
});
Upvotes: 0
Reputation: 17863
Actually, new breeze.EntityManager(...)
always produces a clean manager with an empty metadataStore
. Look at the network traffic and you'll see that a new manager requests metadata from the server on its first query.
You have to want to avoid that squeaky clean behavior ... and I usually do want to avoid that behavior.
Usually, if I've acquired the metadata once and initialized my manager with it, I want to create new managers that are set up in the same way. And you can:
// manager2 has manager1's settings but not its cache contents
var manager2 = manager1.createEmptyCopy();
But I guess in your case you desire the default.
Upvotes: 3