The MetadataStore.importMetadata method supports “custom” nodes at the entity and property levels.
MetadataStore.proto.importMetadata = function (exportedMetadata, [allowMerge = false])
The MetadataStore.exportMetadata method will automatically include any custom metadata within the store.
The MetadataStore.addEntityType method supports “custom” nodes on both the entity and property level.
For the EntityType, ComplexType, DataProperty and NavigationProperty classes:
var customMetadata = { "structuralTypes": [{ "shortName": "Customer", "namespace": "myNamespace", "dataProperties": [ { "nameOnServer": "CustomerID", "custom": { "description": "This customer's Id", "nestedDp": { "displayName": "Customer Id" } } }, { "name": "companyName", "custom": { "description": "The name of this company", "moreInfo": { hasServerValidation: true, "defaultLocale": "en-gb" } } } ], "navigationProperties": [ { "name": "orders", "custom": { "description": "The orders for this customer", navigation property", "nestedNp": { x: 3, y: 4 z: 7 } } } ], "custom": { "description": "A customer" "nestedXXX": { jsonInterceptorName: "foo", } } }] }; myEntityManager.metadataStore.importMetadata(customMetadata, true);
This example assumes the existence of makeCustomTypeAnnot and makeCustomPropAnnot methods that each create a serializable javascript object.
var store = new MetadataStore(); var eto = {} eto.shortName = "type1"; eto.namespace = "mod1"; eto.dataProperties = new Array(); eto.autoGeneratedKeyType = breeze.AutoGeneratedKeyType.Identity; eto.custom = makeCustomTypeAnnot("type1");
var dpo = {}; dpo.name = "id"; dpo.dataType = breeze.DataType.Int32; dpo.isNullable = false; dpo.isPartOfKey = true; dpo.custom = makeCustomPropAnnot("id");
var dp = new breeze.DataProperty(dpo); eto.dataProperties.push(dp);
var et = new breeze.EntityType(eto); store.addEntityType(et);
var dp = new DataProperty({ "name: "Id", "dataType": breeze.DataType.Int32, "isNullable" false, "isPartOfKey": true "custom" { "foo": "fooValue", "bar": { x: 3, y: 14, canShow: true } } });
var customerType = myEntityManager.metadataStore.getEntityType("Customer") var customerCustomMetadata = customerType.custom; var companyNameProp = customerType.getProperty("companyName"); var companyNameCustomMetadata = companyNameProp.custom;