私は次のようにコードを呼び出します:
var studyDataService = new breeze.DataService({ serviceName: _config.RemoteStudyDataServiceName, hasServerMetadata: false });
var mgr = new breeze.EntityManager({ dataService: studyDataService });
mgr.metadataStore.importMetadata(mmg.StudyMetadata);
また、スキーマはサーバー側の /Metadata エンドポイントから取得されます。それはすぐには機能しませんでしたが、metadataStore.exportMetadata() を使用してその文字列を保存し、それをスクリプトに入れました。次のようになります。
mmg.StudyMetadata = {
"schema":
{
"namespace": "CodeFirstNamespace",
"alias": "Self",
"d4p1:UseStrongSpatialTypes": "false",
"xmlns:d4p1": "http://schemas.microsoft.com/ado/2009/02/edm/annotation",
"xmlns": "http://schemas.microsoft.com/ado/2009/11/edm",
"cSpaceOSpaceMapping": {
"CodeFirstNamespace.Study": "MMG.Legacy.StudySiteComm.Core.Entities.Study",
"CodeFirstNamespace.StudySite": "MMG.Legacy.StudySiteComm.Core.Entities.StudySite",
"CodeFirstNamespace.SiteContact": "MMG.Legacy.StudySiteComm.Core.Entities.SiteContact"
},
"entityType": [{ "name": "Study", "key": { "propertyRef": { "name": "StudyID" } }, "property": [{ "name": "StudyID", "type": "Edm.Int32", "nullable": "false", "d4p1:StoreGeneratedPattern": "Identity" }, { "name": "StudyName", "type": "Edm.String", "fixedLength": "false", "maxLength": "100", "unicode": "true", "nullable": "false" }, { "name": "ClientName", "type": "Edm.String", "fixedLength": "false", "maxLength": "100", "unicode": "true", "nullable": "false" }], "navigationProperty": { "name": "StudySites", "relationship": "Self.StudySite_Study", "fromRole": "StudySite_Study_Target", "toRole": "StudySite_Study_Source" } },
{ "name": "StudySite", "key": { "propertyRef": { "name": "SiteID" } }, "property": [{ "name": "StudyID", "type": "Edm.Int32", "nullable": "true" }, { "name": "SiteID", "type": "Edm.Int32", "nullable": "false", "d4p1:StoreGeneratedPattern": "Identity" }, { "name": "ClientID", "type": "Edm.String", "fixedLength": "false", "maxLength": "12", "unicode": "true", "nullable": "false" }], "navigationProperty": [{ "name": "Contacts", "relationship": "Self.SiteContact_StudySite", "fromRole": "SiteContact_StudySite_Target", "toRole": "SiteContact_StudySite_Source" }, { "name": "Study", "relationship": "Self.StudySite_Study", "fromRole": "StudySite_Study_Source", "toRole": "StudySite_Study_Target" }] },
{ "name": "SiteContact", "key": { "propertyRef": { "name": "ContactID" } }, "property": [{ "name": "ContactID", "type": "Edm.Int32", "nullable": "false", "d4p1:StoreGeneratedPattern": "Identity" }, { "name": "StudySiteID", "type": "Edm.Int32", "nullable": "true" }, { "name": "FirstName", "type": "Edm.String", "fixedLength": "false", "maxLength": "50", "unicode": "true", "nullable": "true" }, { "name": "LastName", "type": "Edm.String", "fixedLength": "false", "maxLength": "50", "unicode": "true", "nullable": "true" }, { "name": "EmailAddress", "type": "Edm.String", "fixedLength": "false", "maxLength": "150", "unicode": "true", "nullable": "true" }, { "name": "ContactType", "type": "Edm.Self.ContactTypeEnum", "nullable": "false" }], "navigationProperty": { "name": "StudySite", "relationship": "Self.SiteContact_StudySite", "fromRole": "SiteContact_StudySite_Source", "toRole": "SiteContact_StudySite_Target" } }],
"enumType": { "name": "ContactTypeEnum", "isFlags": "false", "underlyingType": "Int32", "member": [{ "name": "PrimaryInvestigator", "value": "0" }, { "name": "StudyCoordinator", "value": "1" }, { "name": "ShippingContact", "value": "2" }, { "name": "CRA", "value": "3" }, { "name": "RecruitmentSpecialist", "value": "4" }, { "name": "Other", "value": "5" }] },
"association": [{ "name": "SiteContact_StudySite", "end": [{ "role": "SiteContact_StudySite_Source", "type": "Edm.Self.SiteContact", "multiplicity": "*" }, { "role": "SiteContact_StudySite_Target", "type": "Edm.Self.StudySite", "multiplicity": "0..1" }], "referentialConstraint": { "principal": { "role": "SiteContact_StudySite_Target", "propertyRef": { "name": "SiteID" } }, "dependent": { "role": "SiteContact_StudySite_Source", "propertyRef": { "name": "StudySiteID" } } } }, { "name": "StudySite_Study", "end": [{ "role": "StudySite_Study_Source", "type": "Edm.Self.StudySite", "multiplicity": "*" }, { "role": "StudySite_Study_Target", "type": "Edm.Self.Study", "multiplicity": "0..1" }], "referentialConstraint": { "principal": { "role": "StudySite_Study_Target", "propertyRef": { "name": "StudyID" } }, "dependent": { "role": "StudySite_Study_Source", "propertyRef": { "name": "StudyID" } } } }],
"entityContainer": { "name": "CodeFirstContainer", "entitySet": [{ "name": "Studies", "entityType": "Self.Study" }, { "name": "StudySites", "entityType": "Self.StudySite" }, { "name": "SiteContacts", "entityType": "Self.SiteContact" }], "associationSet": [{ "name": "SiteContact_StudySite", "association": "Self.SiteContact_StudySite", "end": [{ "role": "SiteContact_StudySite_Source", "entitySet": "SiteContacts" }, { "role": "SiteContact_StudySite_Target", "entitySet": "StudySites" }] }, { "name": "StudySite_Study", "association": "Self.StudySite_Study", "end": [{ "role": "StudySite_Study_Source", "entitySet": "StudySites" }, { "role": "StudySite_Study_Target", "entitySet": "Studies" }] }] }
}
}