protected override BoundedContextElement Create() { if (string.IsNullOrEmpty(_name)) { throw new InvalidOperationException("The context name was not specified."); } Uri uri = Metamodeling.Elements.Identities.Builder.Metadata.Id.For <QueryingMetadataIdentity>(_name); var contextId = uri.AsIdentity(); StructuralModelElement conceptualModel = null; StructuralModelElement storeModel = null; if (_conceptualModel != null) { conceptualModel = _conceptualModel; Childs(conceptualModel); } if (_storeModel != null) { storeModel = _storeModel; Childs(storeModel); } ProcessMappings(conceptualModel, storeModel); return(new BoundedContextElement(contextId, conceptualModel, storeModel, Features)); }
private IEdmModel BuildModel(string namespaceName, StructuralModelElement conceptualModelElement) { var model = new EdmModel(); var container = new EdmEntityContainer(namespaceName, DefaultContainerName); model.AddElement(container); var typeBuilder = new TypeBuilder(namespaceName); BuildEntitySets(container, conceptualModelElement.RootEntities, typeBuilder); BuildTypes(model, conceptualModelElement.Entities, typeBuilder); return model; }
private IEdmModel BuildModel(string namespaceName, StructuralModelElement conceptualModelElement) { var model = new EdmModel(); var container = new EdmEntityContainer(namespaceName, DefaultContainerName); model.AddElement(container); var typeBuilder = new TypeBuilder(namespaceName); BuildEntitySets(container, conceptualModelElement.RootEntities, typeBuilder); BuildTypes(model, conceptualModelElement.Entities, typeBuilder); return(model); }
private void ProcessMappings(StructuralModelElement conceptualModel, StructuralModelElement storeModel) { if (conceptualModel == null || storeModel == null) { return; } var conceptualEntities = conceptualModel.Entities.ToDictionary(x => x.Identity.Id); var storeEntities = storeModel.Entities.ToDictionary(x => x.Identity.Id); foreach (var map in _entityMap) { EntityElement conceptualEntity; EntityElement storeEntity; if (!conceptualEntities.TryGetValue(map.Key, out conceptualEntity) || !storeEntities.TryGetValue(map.Value, out storeEntity)) { throw new InvalidOperationException("The entity mapping cannot be resolved."); } ((IMetadataElementUpdater)conceptualEntity).AddFeature(new ElementMappingFeature(storeEntity)); } }