internal FunctionImportMapping(EDMXFile parentFile, CSMapping csMapping, XmlElement fimElement)
     : base(parentFile)
 {
     _csMapping  = csMapping;
     _fimElement = fimElement;
     ModelFunction mf = this.ModelFunction;
 }
        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 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 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);
        }
Beispiel #5
0
        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 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 AssociationSetMapping(EDMXFile parentFile, CSMapping csMapping, XmlElement asmElement)
     : base(parentFile)
 {
     _csMapping  = csMapping;
     _asmElement = asmElement;
 }
 internal EntitySetMapping(EDMXFile parentFile, CSMapping csMapping, XmlElement esmElement)
     : base(parentFile)
 {
     _csMapping = csMapping;
     _esmElement = esmElement;
 }
Beispiel #9
0
 internal EntitySetMapping(EDMXFile parentFile, CSMapping csMapping, XmlElement esmElement)
     : base(parentFile)
 {
     _csMapping  = csMapping;
     _esmElement = esmElement;
 }
 internal AssociationSetMapping(EDMXFile parentFile, CSMapping csMapping, XmlElement asmElement)
     : base(parentFile)
 {
     _csMapping = csMapping;
     _asmElement = asmElement;
 }