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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a mapping between a model entity set and one or more store entitysets.
        /// </summary>
        /// <param name="modelEntitySet">Model entityset to add mapping for.</param>
        /// <param name="storeEntitySets">One or several store entitysets mapped to the model entity set.</param>
        /// <returns>An EntitySetMapping object.</returns>
        public EntitySetMapping AddMapping(ModelEntitySet modelEntitySet, params StoreEntitySet[] storeEntitySets)
        {
            EntitySetMapping esm = new EntitySetMapping(base.ParentFile, _entityContainerMapping, this, modelEntitySet, storeEntitySets);

            _entitySetMappings.Add(esm.ModelEntitySet.Name, esm);
            esm.Removed += new EventHandler(esm_Removed);
            esm.ModelEntitySet.NameChanged += new EventHandler <NameChangeArgs>(ModelEntitySet_NameChanged);
            return(esm);
        }
Exemplo n.º 4
0
 void ModelEntitySet_NameChanged(object sender, NameChangeArgs e)
 {
     if (_entitySetMappings.ContainsKey(e.OldName))
     {
         EntitySetMapping esm = _entitySetMappings[e.OldName];
         _entitySetMappings.Remove(e.OldName);
         _entitySetMappings.Add(e.NewName, esm);
     }
 }
Exemplo n.º 5
0
        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 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));
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Adds a mapping between a model entity set and one or more store entitysets.
 /// </summary>
 /// <param name="modelEntitySet">Model entityset to add mapping for.</param>
 /// <param name="storeEntitySets">One or several store entitysets mapped to the model entity set.</param>
 /// <returns>An EntitySetMapping object.</returns>
 public EntitySetMapping AddMapping(ModelEntitySet modelEntitySet, params StoreEntitySet[] storeEntitySets)
 {
     EntitySetMapping esm = new EntitySetMapping(base.ParentFile, _entityContainerMapping, this, modelEntitySet, storeEntitySets);
     _entitySetMappings.Add(esm.ModelEntitySet.Name, esm);
     esm.Removed += new EventHandler(esm_Removed);
     esm.ModelEntitySet.NameChanged += new EventHandler<NameChangeArgs>(ModelEntitySet_NameChanged);
     return esm;
 }
Exemplo n.º 8
0
 internal void CSMappingsUpdated()
 {
     _entitySetMapping = null;
 }
Exemplo n.º 9
0
 void _entitySetMapping_Removed(object sender, EventArgs e)
 {
     _entitySetMapping = null;
 }
Exemplo n.º 10
0
 void _entitySetMapping_Removed(object sender, EventArgs e)
 {
     _entitySetMapping = null;
 }
Exemplo n.º 11
0
 internal void CSMappingsUpdated()
 {
     _entitySetMapping = null;
 }