示例#1
0
 private void ExtractProperties(
     IEnumerable <PropertyMapping> properties,
     MemberPath cNode,
     List <ProjectedSlot> cSlots,
     ref BoolExpression cQueryWhereClause,
     MemberPath sRootExtent,
     List <ProjectedSlot> sSlots,
     ref BoolExpression sQueryWhereClause)
 {
     foreach (PropertyMapping property in properties)
     {
         ScalarPropertyMapping    scalarPropertyMapping  = property as ScalarPropertyMapping;
         ComplexPropertyMapping   complexPropertyMapping = property as ComplexPropertyMapping;
         EndPropertyMapping       endPropertyMapping     = property as EndPropertyMapping;
         ConditionPropertyMapping conditionMap           = property as ConditionPropertyMapping;
         if (scalarPropertyMapping != null)
         {
             MemberPath node1 = new MemberPath(cNode, (EdmMember)scalarPropertyMapping.Property);
             MemberPath node2 = new MemberPath(sRootExtent, (EdmMember)scalarPropertyMapping.Column);
             cSlots.Add((ProjectedSlot) new MemberProjectedSlot(node1));
             sSlots.Add((ProjectedSlot) new MemberProjectedSlot(node2));
         }
         if (complexPropertyMapping != null)
         {
             foreach (ComplexTypeMapping typeMapping in complexPropertyMapping.TypeMappings)
             {
                 MemberPath            memberPath = new MemberPath(cNode, (EdmMember)complexPropertyMapping.Property);
                 Set <EdmType>         set        = new Set <EdmType>();
                 IEnumerable <EdmType> elements   = Helpers.AsSuperTypeList <ComplexType, EdmType>((IEnumerable <ComplexType>)typeMapping.Types);
                 set.AddRange(elements);
                 foreach (EdmType isOfType in typeMapping.IsOfTypes)
                 {
                     set.AddRange(MetadataHelper.GetTypeAndSubtypesOf(isOfType, (ItemCollection)this.m_containerMapping.StorageMappingItemCollection.EdmItemCollection, false));
                 }
                 BoolExpression literal = BoolExpression.CreateLiteral((BoolLiteral) new TypeRestriction(memberPath, (IEnumerable <EdmType>)set), (MemberDomainMap)null);
                 cQueryWhereClause = BoolExpression.CreateAnd(cQueryWhereClause, literal);
                 this.ExtractProperties((IEnumerable <PropertyMapping>)typeMapping.AllProperties, memberPath, cSlots, ref cQueryWhereClause, sRootExtent, sSlots, ref sQueryWhereClause);
             }
         }
         if (endPropertyMapping != null)
         {
             MemberPath cNode1 = new MemberPath(cNode, (EdmMember)endPropertyMapping.AssociationEnd);
             this.ExtractProperties((IEnumerable <PropertyMapping>)endPropertyMapping.PropertyMappings, cNode1, cSlots, ref cQueryWhereClause, sRootExtent, sSlots, ref sQueryWhereClause);
         }
         if (conditionMap != null)
         {
             if (conditionMap.Column != null)
             {
                 BoolExpression conditionExpression = CellCreator.GetConditionExpression(sRootExtent, conditionMap);
                 sQueryWhereClause = BoolExpression.CreateAnd(sQueryWhereClause, conditionExpression);
             }
             else
             {
                 BoolExpression conditionExpression = CellCreator.GetConditionExpression(cNode, conditionMap);
                 cQueryWhereClause = BoolExpression.CreateAnd(cQueryWhereClause, conditionExpression);
             }
         }
     }
 }
        internal static ViewGenResults GenerateViewsFromMapping(
            EntityContainerMapping containerMapping,
            ConfigViewGenerator config)
        {
            CellCreator    cellCreator = new CellCreator(containerMapping);
            List <Cell>    cells       = cellCreator.GenerateCells();
            CqlIdentifiers identifiers = cellCreator.Identifiers;

            return(ViewgenGatekeeper.GenerateViewsFromCells(cells, config, identifiers, containerMapping));
        }
示例#3
0
        /// <summary>
        ///     Entry point for View Generation
        /// </summary>
        /// <param name="containerMapping"> </param>
        /// <param name="workSpace"> </param>
        /// <param name="config"> </param>
        /// <returns> Generated Views for EntitySets </returns>
        internal static ViewGenResults GenerateViewsFromMapping(StorageEntityContainerMapping containerMapping, ConfigViewGenerator config)
        {
            DebugCheck.NotNull(containerMapping);
            DebugCheck.NotNull(config);
            Debug.Assert(containerMapping.HasViews, "Precondition Violated: No mapping exists to generate views for!");

            //Create Cells from StorageEntityContainerMapping
            var cellCreator = new CellCreator(containerMapping);
            var cells       = cellCreator.GenerateCells();
            var identifiers = cellCreator.Identifiers;

            return(GenerateViewsFromCells(cells, config, identifiers, containerMapping));
        }
        /// <summary>
        ///     Entry point for View Generation
        /// </summary>
        /// <param name="containerMapping"> </param>
        /// <param name="workSpace"> </param>
        /// <param name="config"> </param>
        /// <returns> Generated Views for EntitySets </returns>
        internal static ViewGenResults GenerateViewsFromMapping(StorageEntityContainerMapping containerMapping, ConfigViewGenerator config)
        {
            DebugCheck.NotNull(containerMapping);
            DebugCheck.NotNull(config);
            Debug.Assert(containerMapping.HasViews, "Precondition Violated: No mapping exists to generate views for!");

            //Create Cells from StorageEntityContainerMapping
            var cellCreator = new CellCreator(containerMapping);
            var cells = cellCreator.GenerateCells();
            var identifiers = cellCreator.Identifiers;

            return GenerateViewsFromCells(cells, config, identifiers, containerMapping);
        }
        /// <summary>
        /// Entry point for View Generation
        /// </summary>
        /// <param name="containerMapping"></param>
        /// <param name="workSpace"></param>
        /// <param name="config"></param>
        /// <returns>Generated Views for EntitySets</returns>
        internal static ViewGenResults GenerateViewsFromMapping(StorageEntityContainerMapping containerMapping, ConfigViewGenerator config)
        {
            Contract.Requires(containerMapping != null);
            Contract.Requires(config != null);
            Debug.Assert(containerMapping.HasViews, "Precondition Violated: No mapping exists to generate views for!");

#if DEBUG
            if (config.IsNormalTracing)
            {
                containerMapping.Print(0);
            }
#endif

            //Create Cells from StorageEntityContainerMapping
            var cellCreator = new CellCreator(containerMapping);
            var cells = cellCreator.GenerateCells();
            var identifiers = cellCreator.Identifiers;

            return GenerateViewsFromCells(cells, config, identifiers, containerMapping);
        }
示例#6
0
        private void ExpandCells(List <Cell> cells)
        {
            Set <MemberPath> set1 = new Set <MemberPath>();

            foreach (Cell cell1 in cells)
            {
                Cell cell = cell1;
                foreach (MemberPath element in cell.SQuery.GetProjectedMembers().Where <MemberPath>((Func <MemberPath, bool>)(member => CellCreator.IsBooleanMember(member))).Where <MemberPath>((Func <MemberPath, bool>)(boolMember => cell.SQuery.GetConjunctsFromWhereClause().Where <MemberRestriction>((Func <MemberRestriction, bool>)(restriction => restriction.Domain.Values.Contains <Constant>(Constant.NotNull))).Select <MemberRestriction, MemberPath>((Func <MemberRestriction, MemberPath>)(restriction => restriction.RestrictedMemberSlot.MemberPath)).Contains <MemberPath>(boolMember))))
                {
                    set1.Add(element);
                }
            }
            Dictionary <MemberPath, Set <MemberPath> > dictionary = new Dictionary <MemberPath, Set <MemberPath> >();

            foreach (Cell cell1 in cells)
            {
                Cell cell = cell1;
                foreach (MemberPath index in set1)
                {
                    IEnumerable <MemberPath> elements = cell.SQuery.GetProjectedPositions(index).Select <int, MemberPath>((Func <int, MemberPath>)(pos => ((MemberProjectedSlot)cell.CQuery.ProjectedSlotAt(pos)).MemberPath));
                    Set <MemberPath>         set2     = (Set <MemberPath>)null;
                    if (!dictionary.TryGetValue(index, out set2))
                    {
                        set2 = new Set <MemberPath>();
                        dictionary[index] = set2;
                    }
                    set2.AddRange(elements);
                }
            }
            foreach (Cell originalCell in cells.ToArray())
            {
                foreach (MemberPath memberToExpand1 in set1)
                {
                    Set <MemberPath> set2 = dictionary[memberToExpand1];
                    if (originalCell.SQuery.GetProjectedMembers().Contains <MemberPath>(memberToExpand1))
                    {
                        Cell result = (Cell)null;
                        if (this.TryCreateAdditionalCellWithCondition(originalCell, memberToExpand1, true, ViewTarget.UpdateView, out result))
                        {
                            cells.Add(result);
                        }
                        if (this.TryCreateAdditionalCellWithCondition(originalCell, memberToExpand1, false, ViewTarget.UpdateView, out result))
                        {
                            cells.Add(result);
                        }
                    }
                    else
                    {
                        foreach (MemberPath memberToExpand2 in originalCell.CQuery.GetProjectedMembers().Intersect <MemberPath>((IEnumerable <MemberPath>)set2))
                        {
                            Cell result = (Cell)null;
                            if (this.TryCreateAdditionalCellWithCondition(originalCell, memberToExpand2, true, ViewTarget.QueryView, out result))
                            {
                                cells.Add(result);
                            }
                            if (this.TryCreateAdditionalCellWithCondition(originalCell, memberToExpand2, false, ViewTarget.QueryView, out result))
                            {
                                cells.Add(result);
                            }
                        }
                    }
                }
            }
        }