internal void UpdateFromJNode(JNode jNode) { var shortName = jNode.Get <String>("shortName"); var ns = jNode.Get <String>("namespace"); var name = TypeNameInfo.QualifyTypeName(shortName, ns); var et = MetadataStore.Instance.GetEntityType(name); Check(et.BaseEntityTypeName, jNode.Get <String>("baseTypeName"), "BaseEntityType"); // For now this doesn't need to match et.IsAbstract = jNode.Get <bool>("isAbstract"); et.AutoGeneratedKeyType = jNode.GetEnum <AutoGeneratedKeyType>("autoGeneratedKeyType"); var drn = jNode.Get <String>("defaultResourceName"); if (drn != null) { MetadataStore.Instance.SetResourceName(drn, et, true); } jNode.GetJNodeArray("dataProperties").ForEach(jn => { var dpName = jn.Get <String>("name"); var dp = et.GetDataProperty(dpName); dp.UpdateFromJNode(jn); }); jNode.GetJNodeArray("navigationProperties").ForEach(jn => { var npName = jn.Get <String>("name"); var np = et.GetNavigationProperty(npName); np.UpdateFromJNode(jn); }); et._validators = new ValidatorCollection(jNode.GetJNodeArray("validators")); // custom }
internal override void UpdateFromJNode(JNode jNode, bool isFromServer) { var name = this.MetadataStore.GetStructuralTypeNameFromJNode(jNode, isFromServer); var et = MetadataStore.GetEntityType(name); var baseTypeName = this.MetadataStore.GetStructuralTypeNameFromJNode(jNode, "baseTypeName", isFromServer); if (baseTypeName != null) { Check(et.BaseEntityTypeName, baseTypeName, "BaseEntityType"); } // For now this doesn't need to match et.IsAbstract = jNode.Get <bool>("isAbstract"); et.AutoGeneratedKeyType = jNode.GetEnum <AutoGeneratedKeyType>("autoGeneratedKeyType"); var drn = jNode.Get <String>("defaultResourceName"); if (drn != null) { MetadataStore.SetResourceName(drn, et, true); } jNode.GetJNodeArray("dataProperties").ForEach(jn => { var dpName = GetPropertyNameFromJNode(jn); var dp = et.GetDataProperty(dpName); if (dp == null) { MetadataStore.OnMetadataMismatch(name, dpName, MetadataMismatchTypes.MissingCLRDataProperty); return; } dp.UpdateFromJNode(jn, isFromServer); }); jNode.GetJNodeArray("navigationProperties").ForEach(jn => { var npName = GetPropertyNameFromJNode(jn); var np = et.GetNavigationProperty(npName); if (np == null) { MetadataStore.OnMetadataMismatch(name, npName, MetadataMismatchTypes.MissingCLRNavigationProperty); return; } np.UpdateFromJNode(jn, isFromServer); }); et._validators = new ValidatorCollection(jNode.GetJNodeArray("validators")); // custom // next 2 lines are only needed if importing 'native' breeze metadata. if (et.KeyProperties.Count == 1 && et.AutoGeneratedKeyType != AutoGeneratedKeyType.None) { et.KeyProperties.First().IsAutoIncrementing = true; } }