Breeze metadata is information about all the objects you have to work with. You can fetch metadata from server-side or you can create metadata by yourself and work with it.
If you want to work with your server-side objects in breeze you create an entity manager with var entityManager = new breeze.EntityManager('api/Db');
where api/db is your asp.net controller. This controller should have a Metadata()
method which returns repository.Metadata()
. In js you call entityManager.fetchMetadata().then(success, failed);
After the promise of fetchMetadata()
is resolved, breeze metadata of variable entityManager
is full-filled and you can start working with your server-side objects in js with breeze!
But you can also work without any metadata from server-side and create it on the fly in your js code. You create your own metadataStore, attach it to entitymanager. Pseudo code:
var myMetadataStore = new breeze.MetadataStore();
myMetadataStore.addEntityType({...});
var dataService = new breeze.DataService({
serviceName: 'demo',
hasServerMetadata: false
});
var entityManager = new breeze.EntityManager({
dataService: dataService,
myMetadataStore: store
});
var entity = manager.createEntity(...);
Here is a working sample from breeze with on-the-fly metadata http://www.breezejs.com/breeze-labs/breezedirectivesvalidation You click on code button or just go to http://plnkr.co/edit/lxPAbIJmRaLmyagXQAFC?p=info to see sources
Also take a look at this link in breeze docs http://www.breezejs.com/documentation/metadata