internal static void PropagateUpdateDomainToQueryDomain(
     IEnumerable <Cell> cells,
     MemberDomainMap queryDomainMap,
     MemberDomainMap updateDomainMap)
 {
     foreach (Cell cell in cells)
     {
         CellQuery cquery = cell.CQuery;
         CellQuery squery = cell.SQuery;
         for (int slotNum = 0; slotNum < cquery.NumProjectedSlots; ++slotNum)
         {
             MemberProjectedSlot memberProjectedSlot1 = cquery.ProjectedSlotAt(slotNum) as MemberProjectedSlot;
             MemberProjectedSlot memberProjectedSlot2 = squery.ProjectedSlotAt(slotNum) as MemberProjectedSlot;
             if (memberProjectedSlot1 != null && memberProjectedSlot2 != null)
             {
                 MemberPath memberPath1 = memberProjectedSlot1.MemberPath;
                 MemberPath memberPath2 = memberProjectedSlot2.MemberPath;
                 queryDomainMap.GetDomainInternal(memberPath1).Unite(updateDomainMap.GetDomainInternal(memberPath2).Where <Constant>((Func <Constant, bool>)(constant =>
                 {
                     if (!constant.IsNull())
                     {
                         return(!(constant is NegatedConstant));
                     }
                     return(false);
                 })));
                 if (updateDomainMap.IsConditionMember(memberPath2) && !queryDomainMap.IsConditionMember(memberPath1))
                 {
                     queryDomainMap.m_projectedConditionMembers.Add(memberPath1);
                 }
             }
         }
     }
     MemberDomainMap.ExpandNegationsInDomainMap(queryDomainMap.m_conditionDomainMap);
     MemberDomainMap.ExpandNegationsInDomainMap(queryDomainMap.m_nonConditionDomainMap);
 }
        internal IEnumerable <MemberPath> GetMembers(
            EdmType edmType,
            bool?isScalar,
            bool?isConditional,
            bool?isPartOfKey,
            MemberDomainMap domainMap)
        {
            MemberPath     currentPath    = this;
            StructuralType structuralType = (StructuralType)edmType;

            foreach (EdmMember member1 in structuralType.Members)
            {
                if (member1 is AssociationEndMember)
                {
                    foreach (MemberPath member2 in new MemberPath(currentPath, member1).GetMembers((EdmType)((RefType)member1.TypeUsage.EdmType).ElementType, isScalar, isConditional, new bool?(true), domainMap))
                    {
                        yield return(member2);
                    }
                }
                bool isActuallyScalar = MetadataHelper.IsNonRefSimpleMember(member1);
                if (isScalar.HasValue)
                {
                    bool?nullable = isScalar;
                    bool flag     = isActuallyScalar;
                    if ((nullable.GetValueOrDefault() != flag ? 0 : (nullable.HasValue ? 1 : 0)) == 0)
                    {
                        continue;
                    }
                }
                EdmProperty childProperty = member1 as EdmProperty;
                if (childProperty != null)
                {
                    bool isActuallyKey = MetadataHelper.IsPartOfEntityTypeKey((EdmMember)childProperty);
                    if (isPartOfKey.HasValue)
                    {
                        bool?nullable = isPartOfKey;
                        bool flag     = isActuallyKey;
                        if ((nullable.GetValueOrDefault() != flag ? 0 : (nullable.HasValue ? 1 : 0)) == 0)
                        {
                            continue;
                        }
                    }
                    MemberPath childPath             = new MemberPath(currentPath, (EdmMember)childProperty);
                    bool       isActuallyConditional = domainMap.IsConditionMember(childPath);
                    if (isConditional.HasValue)
                    {
                        bool?nullable = isConditional;
                        bool flag     = isActuallyConditional;
                        if ((nullable.GetValueOrDefault() != flag ? 0 : (nullable.HasValue ? 1 : 0)) == 0)
                        {
                            continue;
                        }
                    }
                    yield return(childPath);
                }
            }
        }
Exemplo n.º 3
0
        internal IEnumerable <MemberPath> GetMembers(
            EdmType edmType, bool?isScalar, bool?isConditional, bool?isPartOfKey, MemberDomainMap domainMap)
        {
            var currentPath    = this;
            var structuralType = (StructuralType)edmType;

            foreach (var edmMember in structuralType.Members)
            {
                if (edmMember is AssociationEndMember)
                {
                    // get end's keys
                    foreach (var endKey in new MemberPath(currentPath, edmMember).GetMembers(
                                 ((RefType)edmMember.TypeUsage.EdmType).ElementType,
                                 isScalar, isConditional, true /*isPartOfKey*/, domainMap))
                    {
                        yield return(endKey);
                    }
                }
                var isActuallyScalar = MetadataHelper.IsNonRefSimpleMember(edmMember);
                if (isScalar == null ||
                    isScalar == isActuallyScalar)
                {
                    var childProperty = edmMember as EdmProperty;
                    if (childProperty != null)
                    {
                        var isActuallyKey = MetadataHelper.IsPartOfEntityTypeKey(childProperty);
                        if (isPartOfKey == null ||
                            isPartOfKey == isActuallyKey)
                        {
                            var childPath             = new MemberPath(currentPath, childProperty);
                            var isActuallyConditional = domainMap.IsConditionMember(childPath);
                            if (isConditional == null ||
                                isConditional == isActuallyConditional)
                            {
                                yield return(childPath);
                            }
                        }
                    }
                }
            }
        }
        // requires: this domainMap has been created for the C-side
        // effects: Fixes the mergedDomain map in this by merging entries
        // available in updateDomainMap
        internal static void PropagateUpdateDomainToQueryDomain(
            IEnumerable <Cell> cells, MemberDomainMap queryDomainMap, MemberDomainMap updateDomainMap)
        {
            foreach (var cell in cells)
            {
                var cQuery = cell.CQuery;
                var sQuery = cell.SQuery;

                for (var i = 0; i < cQuery.NumProjectedSlots; i++)
                {
                    var cSlot = cQuery.ProjectedSlotAt(i) as MemberProjectedSlot;
                    var sSlot = sQuery.ProjectedSlotAt(i) as MemberProjectedSlot;

                    if (cSlot == null ||
                        sSlot == null)
                    {
                        continue;
                    }

                    // Get the domain for sSlot and merge with cSlot's
                    var cPath   = cSlot.MemberPath;
                    var sPath   = sSlot.MemberPath;
                    var cDomain = queryDomainMap.GetDomainInternal(cPath);
                    var sDomain = updateDomainMap.GetDomainInternal(sPath);

                    // skip NULL because if c-side member is nullable, it's already there, and otherwise can't be taken
                    // skip negated because negated values are translated in a special way
                    cDomain.Unite(sDomain.Where(constant => !constant.IsNull() && !(constant is NegatedConstant)));

                    if (updateDomainMap.IsConditionMember(sPath) &&
                        !queryDomainMap.IsConditionMember(cPath))
                    {
                        // record this member so KB knows we have to generate constraints for it
                        queryDomainMap.m_projectedConditionMembers.Add(cPath);
                    }
                }
            }

            ExpandNegationsInDomainMap(queryDomainMap.m_conditionDomainMap);
            ExpandNegationsInDomainMap(queryDomainMap.m_nonConditionDomainMap);
        }
        // requires: this domainMap has been created for the C-side
        // effects: Fixes the mergedDomain map in this by merging entries
        // available in updateDomainMap
        internal static void PropagateUpdateDomainToQueryDomain(
            IEnumerable<Cell> cells, MemberDomainMap queryDomainMap, MemberDomainMap updateDomainMap)
        {
            foreach (var cell in cells)
            {
                var cQuery = cell.CQuery;
                var sQuery = cell.SQuery;

                for (var i = 0; i < cQuery.NumProjectedSlots; i++)
                {
                    var cSlot = cQuery.ProjectedSlotAt(i) as MemberProjectedSlot;
                    var sSlot = sQuery.ProjectedSlotAt(i) as MemberProjectedSlot;

                    if (cSlot == null
                        || sSlot == null)
                    {
                        continue;
                    }

                    // Get the domain for sSlot and merge with cSlot's
                    var cPath = cSlot.MemberPath;
                    var sPath = sSlot.MemberPath;
                    var cDomain = queryDomainMap.GetDomainInternal(cPath);
                    var sDomain = updateDomainMap.GetDomainInternal(sPath);

                    // skip NULL because if c-side member is nullable, it's already there, and otherwise can't be taken
                    // skip negated because negated values are translated in a special way
                    cDomain.Unite(sDomain.Where(constant => !constant.IsNull() && !(constant is NegatedConstant)));

                    if (updateDomainMap.IsConditionMember(sPath)
                        && !queryDomainMap.IsConditionMember(cPath))
                    {
                        // record this member so KB knows we have to generate constraints for it
                        queryDomainMap.m_projectedConditionMembers.Add(cPath);
                    }
                }
            }

            ExpandNegationsInDomainMap(queryDomainMap.m_conditionDomainMap);
            ExpandNegationsInDomainMap(queryDomainMap.m_nonConditionDomainMap);
        }