Exemple #1
0
        private void InitializeEntitySet(EntitySetBase entitySetBase, MetadataWorkspace workspace)
        {
            EntityContainerMapping map = (EntityContainerMapping)this.m_mappingCollection.GetMap((GlobalItem)entitySetBase.EntityContainer);

            if (map.HasViews)
            {
                this.m_mappingCollection.GetGeneratedView(entitySetBase, workspace);
            }
            Set <EntitySet> set = new Set <EntitySet>();

            if (map != null)
            {
                Set <EdmMember>      columns = new Set <EdmMember>();
                EntitySetBaseMapping setMapping;
                if (entitySetBase.BuiltInTypeKind == BuiltInTypeKind.EntitySet)
                {
                    setMapping = map.GetEntitySetMapping(entitySetBase.Name);
                    this.m_serverGenProperties.Unite(ViewLoader.GetMembersWithResultBinding((EntitySetMapping)setMapping));
                }
                else
                {
                    if (entitySetBase.BuiltInTypeKind != BuiltInTypeKind.AssociationSet)
                    {
                        throw new NotSupportedException();
                    }
                    setMapping = map.GetAssociationSetMapping(entitySetBase.Name);
                }
                foreach (MappingFragment mappingFragment in ViewLoader.GetMappingFragments(setMapping))
                {
                    set.Add(mappingFragment.TableSet);
                    this.m_serverGenProperties.AddRange(ViewLoader.FindServerGenMembers(mappingFragment));
                    columns.AddRange(ViewLoader.FindIsNullConditionColumns(mappingFragment));
                }
                if (0 < columns.Count)
                {
                    foreach (MappingFragment mappingFragment in ViewLoader.GetMappingFragments(setMapping))
                    {
                        this.m_isNullConditionProperties.AddRange(ViewLoader.FindPropertiesMappedToColumns(columns, mappingFragment));
                    }
                }
            }
            this.m_affectedTables.Add(entitySetBase, set.MakeReadOnly());
            this.InitializeFunctionMappingTranslators(entitySetBase, map);
            if (entitySetBase.BuiltInTypeKind != BuiltInTypeKind.AssociationSet)
            {
                return;
            }
            AssociationSet associationSet = (AssociationSet)entitySetBase;

            if (this.m_associationSetMetadata.ContainsKey(associationSet))
            {
                return;
            }
            this.m_associationSetMetadata.Add(associationSet, new AssociationSetMetadata(this.m_affectedTables[(EntitySetBase)associationSet], associationSet, workspace));
        }
Exemple #2
0
 private static IEnumerable <EdmMember> FindIsNullConditionColumns(
     MappingFragment mappingFragment)
 {
     foreach (ConditionPropertyMapping conditionPropertyMapping in ViewLoader.FlattenPropertyMappings(mappingFragment.AllProperties).OfType <ConditionPropertyMapping>())
     {
         if (conditionPropertyMapping.Column != null && conditionPropertyMapping.IsNull.HasValue)
         {
             yield return((EdmMember)conditionPropertyMapping.Column);
         }
     }
 }
Exemple #3
0
 private static IEnumerable <EdmMember> FindServerGenMembers(
     MappingFragment mappingFragment)
 {
     foreach (ScalarPropertyMapping scalarPropertyMapping in ViewLoader.FlattenPropertyMappings(mappingFragment.AllProperties).OfType <ScalarPropertyMapping>())
     {
         if (MetadataHelper.GetStoreGeneratedPattern((EdmMember)scalarPropertyMapping.Column) != StoreGeneratedPattern.None)
         {
             yield return((EdmMember)scalarPropertyMapping.Property);
         }
     }
 }
Exemple #4
0
 private static IEnumerable <EdmMember> FindPropertiesMappedToColumns(
     Set <EdmMember> columns,
     MappingFragment mappingFragment)
 {
     foreach (ScalarPropertyMapping scalarPropertyMapping in ViewLoader.FlattenPropertyMappings(mappingFragment.AllProperties).OfType <ScalarPropertyMapping>())
     {
         if (columns.Contains((EdmMember)scalarPropertyMapping.Column))
         {
             yield return((EdmMember)scalarPropertyMapping.Property);
         }
     }
 }
Exemple #5
0
 private static IEnumerable <PropertyMapping> FlattenPropertyMappings(
     ReadOnlyCollection <PropertyMapping> propertyMappings)
 {
     foreach (PropertyMapping propertyMapping in propertyMappings)
     {
         ComplexPropertyMapping complexPropertyMapping = propertyMapping as ComplexPropertyMapping;
         if (complexPropertyMapping != null)
         {
             foreach (ComplexTypeMapping typeMapping in complexPropertyMapping.TypeMappings)
             {
                 foreach (PropertyMapping flattenPropertyMapping in ViewLoader.FlattenPropertyMappings(typeMapping.AllProperties))
                 {
                     yield return(flattenPropertyMapping);
                 }
             }
         }
         else
         {
             yield return(propertyMapping);
         }
     }
 }