示例#1
0
        internal ViewGenerator(
            Set <Cell> cellGroup,
            ConfigViewGenerator config,
            List <ForeignConstraint> foreignKeyConstraints,
            EntityContainerMapping entityContainerMapping)
        {
            this.m_cellGroup              = cellGroup;
            this.m_config                 = config;
            this.m_queryRewriterCache     = new Dictionary <EntitySetBase, QueryRewriter>();
            this.m_foreignKeyConstraints  = foreignKeyConstraints;
            this.m_entityContainerMapping = entityContainerMapping;
            Dictionary <EntityType, Set <EntityType> > inheritanceGraph = MetadataHelper.BuildUndirectedGraphOfTypes(entityContainerMapping.StorageMappingItemCollection.EdmItemCollection);

            this.SetConfiguration(entityContainerMapping);
            this.m_queryDomainMap  = new MemberDomainMap(ViewTarget.QueryView, this.m_config.IsValidationEnabled, (IEnumerable <Cell>)cellGroup, entityContainerMapping.StorageMappingItemCollection.EdmItemCollection, this.m_config, inheritanceGraph);
            this.m_updateDomainMap = new MemberDomainMap(ViewTarget.UpdateView, this.m_config.IsValidationEnabled, (IEnumerable <Cell>)cellGroup, entityContainerMapping.StorageMappingItemCollection.EdmItemCollection, this.m_config, inheritanceGraph);
            MemberDomainMap.PropagateUpdateDomainToQueryDomain((IEnumerable <Cell>)cellGroup, this.m_queryDomainMap, this.m_updateDomainMap);
            ViewGenerator.UpdateWhereClauseForEachCell((IEnumerable <Cell>)cellGroup, this.m_queryDomainMap, this.m_updateDomainMap, this.m_config);
            MemberDomainMap openDomain1 = this.m_queryDomainMap.GetOpenDomain();
            MemberDomainMap openDomain2 = this.m_updateDomainMap.GetOpenDomain();

            foreach (Cell cell in cellGroup)
            {
                cell.CQuery.WhereClause.FixDomainMap(openDomain1);
                cell.SQuery.WhereClause.FixDomainMap(openDomain2);
                cell.CQuery.WhereClause.ExpensiveSimplify();
                cell.SQuery.WhereClause.ExpensiveSimplify();
                cell.CQuery.WhereClause.FixDomainMap(this.m_queryDomainMap);
                cell.SQuery.WhereClause.FixDomainMap(this.m_updateDomainMap);
            }
        }
示例#2
0
        // effects: Creates a ViewGenerator object that is capable of
        // producing query or update mapping views given the relevant schema
        // given the "cells"
        internal ViewGenerator(
            CellGroup cellGroup, ConfigViewGenerator config,
            List <ForeignConstraint> foreignKeyConstraints,
            EntityContainerMapping entityContainerMapping)
        {
            m_cellGroup              = cellGroup;
            m_config                 = config;
            m_queryRewriterCache     = new Dictionary <EntitySetBase, QueryRewriter>();
            m_foreignKeyConstraints  = foreignKeyConstraints;
            m_entityContainerMapping = entityContainerMapping;

            var inheritanceGraph =
                MetadataHelper.BuildUndirectedGraphOfTypes(entityContainerMapping.StorageMappingItemCollection.EdmItemCollection);

            SetConfiguration(entityContainerMapping);

            // We fix all the cells at this point
            m_queryDomainMap = new MemberDomainMap(
                ViewTarget.QueryView, m_config.IsValidationEnabled, cellGroup,
                entityContainerMapping.StorageMappingItemCollection.EdmItemCollection, m_config, inheritanceGraph);
            m_updateDomainMap = new MemberDomainMap(
                ViewTarget.UpdateView, m_config.IsValidationEnabled, cellGroup,
                entityContainerMapping.StorageMappingItemCollection.EdmItemCollection, m_config, inheritanceGraph);

            // We now go and fix the queryDomain map so that it has all the
            // values from the S-side as well -- this is needed for domain
            // constraint propagation, i.e., values from the S-side get
            // propagated to te oneOfConst on the C-side. So we better get
            // the "possibleValues" stuff to contain those constants as well
            MemberDomainMap.PropagateUpdateDomainToQueryDomain(cellGroup, m_queryDomainMap, m_updateDomainMap);

            UpdateWhereClauseForEachCell(cellGroup, m_queryDomainMap, m_updateDomainMap, m_config);

            // We need to simplify cell queries, yet we don't want the conditions to disappear
            // So, add an extra value to the domain, temporarily
            var queryOpenDomain  = m_queryDomainMap.GetOpenDomain();
            var updateOpenDomain = m_updateDomainMap.GetOpenDomain();

            // Make sure the WHERE clauses of the cells reflect the changes
            foreach (var cell in cellGroup)
            {
                cell.CQuery.WhereClause.FixDomainMap(queryOpenDomain);
                cell.SQuery.WhereClause.FixDomainMap(updateOpenDomain);
                cell.CQuery.WhereClause.ExpensiveSimplify();
                cell.SQuery.WhereClause.ExpensiveSimplify();
                cell.CQuery.WhereClause.FixDomainMap(m_queryDomainMap);
                cell.SQuery.WhereClause.FixDomainMap(m_updateDomainMap);
            }
        }