internal StoreAssociationSet(EDMXFile parentFile, StorageModel storageModel, string name, StoreEntitySet fromES, StoreEntitySet toES, StoreEntityType fromET, StoreEntityType toET, string fromRoleName, string toRoleName, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, List<Tuple<StoreMemberProperty, StoreMemberProperty>> keys) : base(parentFile) { _storageModel = storageModel; _associationSetElement = CreateAssociationSet(); _associationElement = CreateAssociation(name); Name = name; FromRoleName = fromRoleName; ToRoleName = toRoleName; FromEntitySet = fromES; FromEntityType = fromET; FromMultiplicity = fromMultiplicity; ToEntitySet = toES; ToEntityType = toET; ToMultiplicity = toMultiplicity; foreach (Tuple<StoreMemberProperty, StoreMemberProperty> key in keys) { AddKey(key.Item1, key.Item2); } _keysEnumerated = true; }
internal StoreAssociationSet(EDMXFile parentFile, StorageModel storageModel, string name, StoreEntitySet fromES, StoreEntitySet toES, StoreEntityType fromET, StoreEntityType toET, string fromRoleName, string toRoleName, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, List <Tuple <StoreMemberProperty, StoreMemberProperty> > keys) : base(parentFile) { _storageModel = storageModel; _associationSetElement = CreateAssociationSet(); _associationElement = CreateAssociation(name); Name = name; FromRoleName = fromRoleName; ToRoleName = toRoleName; FromEntitySet = fromES; FromEntityType = fromET; FromMultiplicity = fromMultiplicity; ToEntitySet = toES; ToEntityType = toET; ToMultiplicity = toMultiplicity; foreach (Tuple <StoreMemberProperty, StoreMemberProperty> key in keys) { AddKey(key.Item1, key.Item2); } _keysEnumerated = true; }
internal StoreAssociationSet(EDMXFile parentFile, StorageModel storageModel, XmlElement associationSetElement) : base(parentFile) { _storageModel = storageModel; _associationSetElement = associationSetElement; string associationName = _associationSetElement.GetAttribute("Association"); if (!string.IsNullOrEmpty(associationName)) { if (_associationSetElement.ParentNode != null && _associationSetElement.ParentNode.ParentNode != null) { XmlElement schemaElement = (XmlElement)_associationSetElement.ParentNode.ParentNode; string schemaNamespace = schemaElement.GetAttribute("Namespace"); string schemaAlias = schemaElement.GetAttribute("Alias"); if (!string.IsNullOrEmpty(schemaNamespace) && associationName.StartsWith(schemaNamespace)) { associationName = associationName.Substring(schemaNamespace.Length + 1); } else if (!string.IsNullOrEmpty(schemaAlias) && associationName.StartsWith(schemaAlias)) { associationName = associationName.Substring(schemaAlias.Length + 1); } _associationElement = (XmlElement)_associationSetElement.ParentNode.ParentNode.SelectSingleNode("ssdl:Association[@Name=" + XmlHelpers.XPathLiteral(associationName) + "]", NSM); } } if (_associationElement == null) { throw new InvalidModelObjectException("The StoreAssociationSet " + (associationName ?? "[unknown]") + " has no corresponding association element."); } }
internal ModelMemberProperty(EDMXFile parentFile, ModelEntityType modelEntityType, string name, int ordinal, XmlElement entityTypeElement) : base(parentFile) { _modelEntityType = modelEntityType; _modelEntityType.Removed += new EventHandler(ModelEntityType_Removed); _propertyElement = EDMXDocument.CreateElement("Property", NameSpaceURIcsdl); if (ordinal > 0) { XmlNodeList propertyNodes = entityTypeElement.SelectNodes("edm:Property", NSM); if (propertyNodes.Count >= ordinal) { entityTypeElement.InsertAfter(_propertyElement, propertyNodes[ordinal - 1]); } else { entityTypeElement.AppendChild(_propertyElement); } } else { entityTypeElement.AppendChild(_propertyElement); } Name = name; }
internal MappingCondition(EDMXFile parentFile, EntitySetMapping entitySetMapping, XmlElement entitySetMappingElement, ModelEntityType modelEntityType, StoreMemberProperty discriminatorColumn, string discriminatorValue) : base(parentFile) { _entitySetMapping = entitySetMapping; _modelEntityType = modelEntityType; _discriminatorColumn = discriminatorColumn; string storeEntitySetName = discriminatorColumn.EntityType.EntitySet.Name; //get hold of the type mapping _entityTypeMapping = (XmlElement)entitySetMappingElement.SelectSingleNode("map:EntityTypeMapping[@TypeName=" + XmlHelpers.XPathLiteral(modelEntityType.FullName) + " or @TypeName=" + XmlHelpers.XPathLiteral("IsTypeOf(" + modelEntityType.FullName + ")") + " or @TypeName=" + XmlHelpers.XPathLiteral(modelEntityType.AliasName) + " or @TypeName=" + XmlHelpers.XPathLiteral("IsTypeOf(" + modelEntityType.AliasName + ")") + "]", NSM); if (_entityTypeMapping == null) { throw new ArgumentException("The entity type " + modelEntityType.Name + " is not a participant in this entity set mapping."); } _mappingFragment = (XmlElement)_entityTypeMapping.SelectSingleNode("map:MappingFragment[@StoreEntitySet=" + XmlHelpers.XPathLiteral(storeEntitySetName) + "]", NSM); if (_mappingFragment == null) { throw new ArgumentException("The store entityset " + storeEntitySetName + " is not a participant in this entity set mapping."); } _mappingCondition = EDMXDocument.CreateElement("Condition", NameSpaceURImap); _mappingCondition.SetAttribute("ColumnName", discriminatorColumn.Name); if (discriminatorValue != null) { _mappingCondition.SetAttribute("Value", discriminatorValue); } else { _mappingCondition.SetAttribute("IsNull", "true"); } _mappingFragment.AppendChild(_mappingCondition); }
internal StoreMemberProperty(EDMXFile parentFile, StoreEntityType storeEntityType, string name, int ordinal, XmlElement parentTypeElement) : base(parentFile) { _parentEntityType = storeEntityType; _parentEntityType.Removed += new EventHandler(ParentEntityType_Removed); _propertyElement = EDMXDocument.CreateElement("Property", NameSpaceURIssdl); if (ordinal > 0) { XmlNodeList propertyNodes = parentTypeElement.SelectNodes("ssdl:Property", NSM); if (propertyNodes.Count >= ordinal) { parentTypeElement.InsertAfter(_propertyElement, propertyNodes[ordinal - 1]); } else { parentTypeElement.AppendChild(_propertyElement); } } else { parentTypeElement.AppendChild(_propertyElement); } this.Name = name; }
internal NavigationProperty(EDMXFile parentFile, ModelEntityType modelEntityType, string name, ModelAssociationSet modelAssociationSet, XmlElement entityTypeElement, string fromRoleName, string toRoleName) : base(parentFile) { _modelEntityType = modelEntityType; _propertyElement = EDMXDocument.CreateElement("NavigationProperty", NameSpaceURIcsdl); _propertyElement.SetAttribute("Relationship", modelAssociationSet.FullName); if (string.IsNullOrEmpty(fromRoleName) || string.IsNullOrEmpty(toRoleName)) { if (modelAssociationSet.FromEntityType == _modelEntityType) { fromRoleName = modelAssociationSet.FromRoleName; toRoleName = modelAssociationSet.ToRoleName; } else { fromRoleName = modelAssociationSet.ToRoleName; toRoleName = modelAssociationSet.FromRoleName; } } _propertyElement.SetAttribute("FromRole", fromRoleName); _propertyElement.SetAttribute("ToRole", toRoleName); entityTypeElement.AppendChild(_propertyElement); Name = name; }
internal StoreFunctionParameter(EDMXFile parentFile, StoreFunction storeFunction, string name, int ordinal, XmlElement parentTypeElement) : base(parentFile) { _parentFunction = storeFunction; _parameterElement = EDMXDocument.CreateElement("Parameter", NameSpaceURIssdl); if (ordinal > 0) { XmlNodeList propertyNodes = parentTypeElement.SelectNodes("ssdl:Parameter", NSM); if (propertyNodes.Count >= ordinal) { parentTypeElement.InsertAfter(_parameterElement, propertyNodes[ordinal - 1]); } else { parentTypeElement.AppendChild(_parameterElement); } } else { parentTypeElement.AppendChild(_parameterElement); } this.Name = name; }
internal StoreMemberProperty(EDMXFile parentFile, StoreEntityType parentEntityType, XmlElement propertyElement) : base(parentFile) { _parentEntityType = parentEntityType; _parentEntityType.Removed += new EventHandler(ParentEntityType_Removed); _propertyElement = propertyElement; }
internal Designer(EDMXFile parentFile) : base(parentFile) { if (parentFile.EDMXVersion == EDMXVersionEnum.EDMX2012 && parentFile.EDMXDiagramDocument != null) { _document = parentFile.EDMXDiagramDocument; } else { _document = EDMXDocument; } //designer wrapper _designerElement = (XmlElement)_document.DocumentElement.SelectSingleNode("edmx:Designer", NSM); //get or create the Diagrams element _diagramsElement = _designerElement.GetOrCreateElement("edmx", "Diagrams", NSM); //get or create the Diagram element _diagramElement = _diagramsElement.GetOrCreateElement("edmx", "Diagram", NSM); if (!_diagramElement.HasAttribute("Name")) { _diagramElement.SetAttribute("Name", "default"); } //get options XmlElement optionsElement = _designerElement.GetOrCreateElement("edmx", "Options", NSM, true); _optionsPropertySetElement = optionsElement.GetOrCreateElement("edmx", "DesignerInfoPropertySet", NSM); }
internal ModelMemberProperty(EDMXFile parentFile, ModelComplexType modelComplexType, XmlElement memberPropertyElement) : base(parentFile) { _modelComplexType = modelComplexType; _modelComplexType.Removed += new EventHandler(ModelComplexType_Removed); _propertyElement = memberPropertyElement; }
internal ModelFunctionParameter(EDMXFile parentFile, ModelFunction storeFunction, string name, int ordinal, XmlElement parentTypeElement) : base(parentFile) { _parentFunction = storeFunction; _parameterElement = EDMXDocument.CreateElement("Parameter", NameSpaceURIcsdl); if (ordinal > 0) { XmlNodeList propertyNodes = parentTypeElement.SelectNodes("edm:Parameter", NSM); if (propertyNodes.Count >= ordinal) { parentTypeElement.InsertAfter(_parameterElement, propertyNodes[ordinal - 1]); } else { parentTypeElement.AppendChild(_parameterElement); } } else { parentTypeElement.AppendChild(_parameterElement); } this.Name = name; }
internal FunctionImportMapping(EDMXFile parentFile, CSMapping csMapping, XmlElement fimElement) : base(parentFile) { _csMapping = csMapping; _fimElement = fimElement; ModelFunction mf = this.ModelFunction; }
internal ModelAssociationSet(EDMXFile parentFile, ConceptualModel conceptualModel, XmlElement associationSetElement) : base(parentFile) { _conceptualModel = conceptualModel; _associationSetElement = associationSetElement; string associationName = _associationSetElement.GetAttribute("Association"); if (!string.IsNullOrEmpty(associationName)) { if (_associationSetElement.ParentNode != null && _associationSetElement.ParentNode.ParentNode != null) { XmlElement schemaElement = (XmlElement)_associationSetElement.ParentNode.ParentNode; string schemaNamespace = schemaElement.GetAttribute("Namespace"); string schemaAlias = schemaElement.GetAttribute("Alias"); if (!string.IsNullOrEmpty(schemaNamespace) && associationName.StartsWith(schemaNamespace)) { associationName = associationName.Substring(schemaNamespace.Length + 1); } else if (!string.IsNullOrEmpty(schemaAlias) && associationName.StartsWith(schemaAlias)) { associationName = associationName.Substring(schemaAlias.Length + 1); } _associationElement = (XmlElement)_associationSetElement.ParentNode.ParentNode.SelectSingleNode("edm:Association[@Name=" + XmlHelpers.XPathLiteral(associationName) + "]", NSM); } } if (_associationElement == null) { throw new InvalidModelObjectException("The ModelAssociationSet " + (associationName ?? "[unknown]") + " has no corresponding association element."); } }
internal AssociationSetMapping(EDMXFile parentFile, XmlElement entityContainerMappingElement, CSMapping csMapping, string name, ModelAssociationSet modelAssocSet, StoreEntitySet storeEntitySet, StoreAssociationSet fromStoreAssocSet, StoreAssociationSet toStoreAssocSet) : base(parentFile) { _csMapping = csMapping; _modelAssociationSet = modelAssocSet; //create mapping xml elements _asmElement = EDMXDocument.CreateElement("AssociationSetMapping", NameSpaceURImap); entityContainerMappingElement.AppendChild(_asmElement); XmlElement fromEndProp = EDMXDocument.CreateElement("EndProperty", NameSpaceURImap); fromEndProp.SetAttribute("Name", modelAssocSet.FromRoleName); _asmElement.AppendChild(fromEndProp); XmlElement toEndProp = EDMXDocument.CreateElement("EndProperty", NameSpaceURImap); toEndProp.SetAttribute("Name", modelAssocSet.ToRoleName); _asmElement.AppendChild(toEndProp); List <Tuple <ModelMemberProperty, StoreMemberProperty, string> > fromKeys = ( from key in fromStoreAssocSet.Keys select new Tuple <ModelMemberProperty, StoreMemberProperty, string>( key.Item2.ModelMembers.FirstOrDefault(mm => mm.EntityType == modelAssocSet.FromEntityType), key.Item1, key.Item2.Name ) ).ToList(); foreach (var key in fromKeys) { XmlElement scalarProperty = EDMXDocument.CreateElement("ScalarProperty", NameSpaceURImap); scalarProperty.SetAttribute("Name", (key.Item1 != null ? key.Item1.Name : key.Item3)); scalarProperty.SetAttribute("ColumnName", key.Item2.Name); fromEndProp.AppendChild(scalarProperty); } List <Tuple <ModelMemberProperty, StoreMemberProperty, string> > toKeys = ( from key in toStoreAssocSet.Keys select new Tuple <ModelMemberProperty, StoreMemberProperty, string>( key.Item2.ModelMembers.FirstOrDefault(mm => mm.EntityType == modelAssocSet.ToEntityType), key.Item1, key.Item2.Name ) ).ToList(); foreach (var key in toKeys) { XmlElement scalarProperty = EDMXDocument.CreateElement("ScalarProperty", NameSpaceURImap); scalarProperty.SetAttribute("Name", (key.Item1 != null ? key.Item1.Name : key.Item3)); scalarProperty.SetAttribute("ColumnName", key.Item2.Name); toEndProp.AppendChild(scalarProperty); } Name = name; StoreEntitySetName = storeEntitySet.Name; TypeName = modelAssocSet.FullName; }
internal EntityTypeShape(EDMXFile parentFile, Designer parentDesigner, ModelEntityType entityType) : base(parentFile) { _parentDesigner = parentDesigner; _shapeElement = parentDesigner.Document.CreateElement("EntityTypeShape", NameSpaceURIedmx); EntityTypeName = entityType.FullName; parentDesigner.DiagramElement.AppendChild(_shapeElement); }
internal AssociationSetMapping(EDMXFile parentFile, XmlElement entityContainerMappingElement, CSMapping csMapping, string name, ModelAssociationSet modelAssocSet, StoreEntitySet storeEntitySet, StoreAssociationSet fromStoreAssocSet, StoreAssociationSet toStoreAssocSet) : base(parentFile) { _csMapping = csMapping; _modelAssociationSet = modelAssocSet; //create mapping xml elements _asmElement = EDMXDocument.CreateElement("AssociationSetMapping", NameSpaceURImap); entityContainerMappingElement.AppendChild(_asmElement); XmlElement fromEndProp = EDMXDocument.CreateElement("EndProperty", NameSpaceURImap); fromEndProp.SetAttribute("Name", modelAssocSet.FromRoleName); _asmElement.AppendChild(fromEndProp); XmlElement toEndProp = EDMXDocument.CreateElement("EndProperty", NameSpaceURImap); toEndProp.SetAttribute("Name", modelAssocSet.ToRoleName); _asmElement.AppendChild(toEndProp); List<Tuple<ModelMemberProperty, StoreMemberProperty, string>> fromKeys = ( from key in fromStoreAssocSet.Keys select new Tuple<ModelMemberProperty, StoreMemberProperty, string>( key.Item2.ModelMembers.FirstOrDefault(mm => mm.EntityType == modelAssocSet.FromEntityType), key.Item1, key.Item2.Name ) ).ToList(); foreach (var key in fromKeys) { XmlElement scalarProperty = EDMXDocument.CreateElement("ScalarProperty", NameSpaceURImap); scalarProperty.SetAttribute("Name", (key.Item1 != null ? key.Item1.Name : key.Item3)); scalarProperty.SetAttribute("ColumnName", key.Item2.Name); fromEndProp.AppendChild(scalarProperty); } List<Tuple<ModelMemberProperty, StoreMemberProperty, string>> toKeys = ( from key in toStoreAssocSet.Keys select new Tuple<ModelMemberProperty, StoreMemberProperty, string>( key.Item2.ModelMembers.FirstOrDefault(mm => mm.EntityType == modelAssocSet.ToEntityType), key.Item1, key.Item2.Name ) ).ToList(); foreach (var key in toKeys) { XmlElement scalarProperty = EDMXDocument.CreateElement("ScalarProperty", NameSpaceURImap); scalarProperty.SetAttribute("Name", (key.Item1 != null ? key.Item1.Name : key.Item3)); scalarProperty.SetAttribute("ColumnName", key.Item2.Name); toEndProp.AppendChild(scalarProperty); } Name = name; StoreEntitySetName = storeEntitySet.Name; TypeName = modelAssocSet.FullName; }
internal ModelMemberProperty(EDMXFile parentFile, ModelComplexType modelComplexType, string name, XmlElement entityTypeElement) : base(parentFile) { _modelComplexType = modelComplexType; _modelComplexType.Removed += new EventHandler(ModelComplexType_Removed); _propertyElement = EDMXDocument.CreateElement("Property", NameSpaceURIcsdl); entityTypeElement.AppendChild(_propertyElement); Name = name; }
internal StoreEntityType(EDMXFile parentFile, StorageModel storageModel, string name) : base(parentFile) { _storageModel = storageModel; //create the entity type element XmlElement schemaContainer = (XmlElement)EDMXDocument.DocumentElement.SelectSingleNode("edmx:Runtime/edmx:StorageModels/ssdl:Schema", NSM); _entityTypeElement = EDMXDocument.CreateElement("EntityType", NameSpaceURIssdl); schemaContainer.AppendChild(_entityTypeElement); Name = name; }
internal ModelFunction(EDMXFile parentFile, ConceptualModel conceptualModel, string name) : base(parentFile) { _conceptualModel = conceptualModel; //create the entity type element XmlElement schemaContainer = (XmlElement)EDMXDocument.DocumentElement.SelectSingleNode("edmx:Runtime/edmx:ConceptualModels/edm:Schema/edm:EntityContainer", NSM); _functionImportElement = EDMXDocument.CreateElement("FunctionImport", NameSpaceURIcsdl); schemaContainer.AppendChild(_functionImportElement); Name = name; }
internal StoreFunction(EDMXFile ParentFile, StorageModel storageModel, string name) : base(ParentFile) { _storageModel = storageModel; //create and add the function element XmlElement schemaContainer = (XmlElement)EDMXDocument.DocumentElement.SelectSingleNode("edmx:Runtime/edmx:StorageModels/ssdl:Schema", NSM); _functionElement = EDMXDocument.CreateElement("Function", NameSpaceURIssdl); schemaContainer.AppendChild(_functionElement); this.Name = name; }
internal StoreEntitySet(EDMXFile parentFile, StorageModel storageModel, string name) : base(parentFile) { _storageModel = storageModel; //create and add the entity set element XmlElement setContainer = (XmlElement)EDMXDocument.DocumentElement.SelectSingleNode("edmx:Runtime/edmx:StorageModels/ssdl:Schema/ssdl:EntityContainer", NSM); _entitySetElement = EDMXDocument.CreateElement("EntitySet", NameSpaceURIssdl); setContainer.AppendChild(_entitySetElement); this.Name = name; }
internal ModelEntitySet(EDMXFile parentFile, ConceptualModel conceptualModel, string name) : base(parentFile) { _conceptualModel = conceptualModel; //create and add the entity set element XmlElement setContainer = (XmlElement)EDMXDocument.DocumentElement.SelectSingleNode("edmx:Runtime/edmx:ConceptualModels/edm:Schema/edm:EntityContainer", NSM); _entitySetElement = EDMXDocument.CreateElement("EntitySet", NameSpaceURIcsdl); setContainer.AppendChild(_entitySetElement); Name = name; }
internal FunctionImportMapping(EDMXFile parentFile, XmlElement entityContainerMappingElement, CSMapping csMapping, ModelFunction modelFunction, StoreFunction storeFunction) : base(parentFile) { _csMapping = csMapping; _modelFunction = modelFunction; _modelFunction.NameChanged += new EventHandler <NameChangeArgs>(ModelFunction_NameChanged); _modelFunction.Removed += new EventHandler(ModelFunction_Removed); _storeFunction = storeFunction; _storeFunction.Removed += new EventHandler(StoreFunction_Removed); }
internal ModelComplexType(EDMXFile parentFile, ConceptualModel conceptualModel, string name) : base(parentFile) { _conceptualModel = conceptualModel; //create the entity type element XmlElement schemaContainer = (XmlElement)EDMXDocument.DocumentElement.SelectSingleNode("edmx:Runtime/edmx:ConceptualModels/edm:Schema", NSM); _complexTypeElement = EDMXDocument.CreateElement("ComplexType", NameSpaceURIcsdl); schemaContainer.AppendChild(_complexTypeElement); Name = name; }
internal ModelEntityType(EDMXFile parentFile, ConceptualModel conceptualModel, string name, ModelEntityType baseType) : base(parentFile) { _conceptualModel = conceptualModel; //create the entity type element XmlElement schemaContainer = (XmlElement)EDMXDocument.DocumentElement.SelectSingleNode("edmx:Runtime/edmx:ConceptualModels/edm:Schema", NSM); _entityTypeElement = EDMXDocument.CreateElement("EntityType", NameSpaceURIcsdl); schemaContainer.AppendChild(_entityTypeElement); BaseType = baseType; Name = name; }
internal EntitySetMapping(EDMXFile parentFile, XmlElement entityContainerMappingElement, CSMapping csMapping, ModelEntitySet modelEntitySet, StoreEntitySet[] storeEntitySets) : base(parentFile) { _csMapping = csMapping; //create mapping xml elements _esmElement = EDMXDocument.CreateElement("EntitySetMapping", NameSpaceURImap); _esmElement.SetAttribute("Name", modelEntitySet.Name); entityContainerMappingElement.AppendChild(_esmElement); //entity type mapping XmlElement entityTypeMapping = EDMXDocument.CreateElement("EntityTypeMapping", NameSpaceURImap); if ((modelEntitySet.EntityType.HasBaseType || modelEntitySet.EntityType.HasSubTypes) && modelEntitySet.InheritanceStrategy != EDMXInheritanceStrategyEnum.TPC) { entityTypeMapping.SetAttribute("TypeName", "IsTypeOf(" + modelEntitySet.EntityType.FullName + ")"); } else { entityTypeMapping.SetAttribute("TypeName", modelEntitySet.EntityType.FullName); } _esmElement.AppendChild(entityTypeMapping); foreach (StoreEntitySet ses in storeEntitySets) { //mapping fragment wrapper XmlElement mappingFragment = EDMXDocument.CreateElement("MappingFragment", NameSpaceURImap); mappingFragment.SetAttribute("StoreEntitySet", ses.Name); entityTypeMapping.AppendChild(mappingFragment); } //keep references to entity sets... _modelEntitySet = modelEntitySet; _storeEntitySets.AddRange(storeEntitySets); //let the involved entity sets know about the change in mappings... modelEntitySet.CSMappingsUpdated(); storeEntitySets.ToList().ForEach(es => es.CSMappingsUpdated()); //hook up remove events _modelEntitySet.Removed += new EventHandler(modelEntitySet_Removed); foreach (StoreEntitySet ses in _storeEntitySets) { ses.Removed += new EventHandler(storeEntitySet_Removed); } }
internal MappingCondition(EDMXFile parentFile, HuagatiEDMXTools.EntitySetMapping entitySetMapping, XmlElement conditionElement) : base(parentFile) { _entitySetMapping = entitySetMapping; _mappingCondition = conditionElement; _mappingFragment = (XmlElement)_mappingCondition.ParentNode; _entityTypeMapping = (XmlElement)_mappingFragment.ParentNode; string entityTypeName = EDMXUtils.StripTypeOf(_entityTypeMapping.GetAttribute("TypeName")); _modelEntityType = ParentFile.ConceptualModel.EntityTypes.FirstOrDefault(et => et.FullName.Equals(entityTypeName, StringComparison.InvariantCultureIgnoreCase) || et.AliasName.Equals(entityTypeName, StringComparison.InvariantCultureIgnoreCase)); if (_modelEntityType != null) { string columnName = _mappingCondition.GetAttribute("ColumnName"); _discriminatorColumn = EntitySetMapping.StoreEntitySetsFor(_modelEntityType).SelectMany(c => c.EntityType.MemberProperties).FirstOrDefault(mp => mp.Name.Equals(columnName, StringComparison.InvariantCultureIgnoreCase)); } }
internal StorageModel(EDMXFile parentFile) : base(parentFile) { _storageModelElement = (XmlElement)EDMXDocument.DocumentElement.SelectSingleNode("edmx:Runtime/edmx:StorageModels", NSM); _schemaElement = (XmlElement)_storageModelElement.SelectSingleNode("ssdl:Schema", NSM); if (_schemaElement == null) { _schemaElement = EDMXDocument.CreateElement("Schema", NameSpaceURIssdl); _storageModelElement.AppendChild(_schemaElement); } _entityContainerElement = (XmlElement)_schemaElement.SelectSingleNode("ssdl:EntityContainer", NSM); if (_entityContainerElement == null) { _entityContainerElement = EDMXDocument.CreateElement("EntityContainer", NameSpaceURIssdl); _schemaElement.AppendChild(_entityContainerElement); } }
internal CSMapping(EDMXFile parentFile) : base(parentFile) { _mappingsElement = (XmlElement)EDMXDocument.DocumentElement.SelectSingleNode("edmx:Runtime/edmx:Mappings", NSM); _mappingElement = (XmlElement)_mappingsElement.SelectSingleNode("map:Mapping", NSM); if (_mappingElement == null) { _mappingElement = EDMXDocument.CreateElement("Mapping", NameSpaceURImap); _mappingElement.SetAttribute("Space", "C-S"); _mappingsElement.AppendChild(_mappingElement); } _entityContainerMapping = (XmlElement)_mappingElement.SelectSingleNode("map:EntityContainerMapping", NSM); if (_entityContainerMapping == null) { _entityContainerMapping = EDMXDocument.CreateElement("EntityContainerMapping", NameSpaceURImap); _mappingElement.AppendChild(_entityContainerMapping); } }
internal ModelAssociationSet(EDMXFile parentFile, ConceptualModel conceptualModel, string name, ModelEntitySet fromES, ModelEntitySet toES, ModelEntityType fromET, ModelEntityType toET, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, string fromNavProperty, string toNavProperty, List <Tuple <ModelMemberProperty, ModelMemberProperty> > keys) : base(parentFile) { _conceptualModel = conceptualModel; bool manyToMany = (fromMultiplicity == MultiplicityTypeEnum.Many && toMultiplicity == MultiplicityTypeEnum.Many); _associationSetElement = CreateAssociationSet(); _associationElement = CreateAssociation(name, manyToMany); Name = name; //set from/to sets and multiplicity FromEntitySet = fromES; FromEntityType = fromET; FromMultiplicity = fromMultiplicity; ToEntitySet = toES; ToEntityType = toET; ToMultiplicity = toMultiplicity; //add navigation properties if (!string.IsNullOrEmpty(fromNavProperty)) { fromET.AddNavigationMember(fromNavProperty, this, FromRoleName, ToRoleName); } if (!string.IsNullOrEmpty(toNavProperty)) { toET.AddNavigationMember(toNavProperty, this, ToRoleName, FromRoleName); } if (keys != null) { foreach (Tuple <ModelMemberProperty, ModelMemberProperty> key in keys) { AddKey(key.Item1, key.Item2); } } _keysEnumerated = true; }
internal ModelAssociationSet(EDMXFile parentFile, ConceptualModel conceptualModel, string name, ModelEntitySet fromES, ModelEntitySet toES, ModelEntityType fromET, ModelEntityType toET, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, string fromNavProperty, string toNavProperty, List<Tuple<ModelMemberProperty, ModelMemberProperty>> keys) : base(parentFile) { _conceptualModel = conceptualModel; bool manyToMany = (fromMultiplicity == MultiplicityTypeEnum.Many && toMultiplicity == MultiplicityTypeEnum.Many); _associationSetElement = CreateAssociationSet(); _associationElement = CreateAssociation(name, manyToMany); Name = name; //set from/to sets and multiplicity FromEntitySet = fromES; FromEntityType = fromET; FromMultiplicity = fromMultiplicity; ToEntitySet = toES; ToEntityType = toET; ToMultiplicity = toMultiplicity; //add navigation properties if (!string.IsNullOrEmpty(fromNavProperty)) { fromET.AddNavigationMember(fromNavProperty, this, FromRoleName, ToRoleName); } if (!string.IsNullOrEmpty(toNavProperty)) { toET.AddNavigationMember(toNavProperty, this, ToRoleName, FromRoleName); } if (keys != null) { foreach (Tuple<ModelMemberProperty, ModelMemberProperty> key in keys) { AddKey(key.Item1, key.Item2); } } _keysEnumerated = true; }
internal AssociationSetMapping(EDMXFile parentFile, CSMapping csMapping, XmlElement asmElement) : base(parentFile) { _csMapping = csMapping; _asmElement = asmElement; }
internal ModelFunction(EDMXFile parentFile, ConceptualModel conceptualModel, System.Xml.XmlElement functionImportElement) : base(parentFile) { _conceptualModel = conceptualModel; _functionImportElement = functionImportElement; }
internal StoreEntitySet(EDMXFile parentFile, StorageModel storageModel, XmlElement entitySetElement) : base(parentFile) { _storageModel = storageModel; _entitySetElement = entitySetElement; }
internal StoreEntityType(EDMXFile parentFile, StorageModel storageModel, XmlElement entityTypeElement) : base(parentFile) { _storageModel = storageModel; _entityTypeElement = entityTypeElement; }
internal EDMXMember(EDMXFile parentFile) { _parentFile = parentFile; }
internal NavigationProperty(EDMXFile parentFile, ModelEntityType modelEntityType, XmlElement navPropertyElement) : base(parentFile) { _modelEntityType = modelEntityType; _propertyElement = navPropertyElement; }
internal EntitySetMapping(EDMXFile parentFile, CSMapping csMapping, XmlElement esmElement) : base(parentFile) { _csMapping = csMapping; _esmElement = esmElement; }
internal ModelEntityType(EDMXFile parentFile, ConceptualModel conceptualModel, System.Xml.XmlElement entityTypeElement) : base(parentFile) { _conceptualModel = conceptualModel; _entityTypeElement = entityTypeElement; }
internal StoreFunction(EDMXFile ParentFile, StorageModel storageModel, XmlElement functionElement) : base(ParentFile) { _storageModel = storageModel; _functionElement = functionElement; }