Esempio n. 1
0
        // requires: domain not have any Negated constants other than NotNull
        // Also, cellQuery contains all final oneOfConsts or all partial oneOfConsts
        // cellquery must contain a whereclause of the form "True", "OneOfConst" or "
        // "OneOfConst AND ... AND OneOfConst"
        // slot must present in cellQuery and incomingDomain is the domain for it
        // effects: Returns the set of values that slot can take as restricted by cellQuery's whereClause
        private static bool TryGetDomainRestrictedByWhereClause(
            IEnumerable <Constant> domain, MemberProjectedSlot slot, CellQuery cellQuery, out CellConstantSet result)
        {
            var conditionsForSlot = cellQuery.GetConjunctsFromWhereClause()
                                    .Where(
                restriction =>
                MemberPath.EqualityComparer.Equals(
                    restriction.RestrictedMemberSlot.MemberPath, slot.MemberPath))
                                    .Select(
                restriction => new CellConstantSet(restriction.Domain.Values, Constant.EqualityComparer));

            //Debug.Assert(!conditionsForSlot.Skip(1).Any(), "More than one Clause with the same path");

            if (!conditionsForSlot.Any())
            {
                // If the slot was not mentioned in the query return the domain without restricting it
                result = new CellConstantSet(domain);
                return(false);
            }

            // Now get all the possible values from domain and conditionValues
            var possibleValues = DeterminePossibleValues(conditionsForSlot.SelectMany(m => m.Select(c => c)), domain);

            var restrictedDomain = new Domain(domain, possibleValues);

            foreach (var conditionValues in conditionsForSlot)
            {
                // Domain derived from Edm-Type INTERSECTED with Conditions
                restrictedDomain = restrictedDomain.Intersect(new Domain(conditionValues, possibleValues));
            }

            result = new CellConstantSet(restrictedDomain.Values, Constant.EqualityComparer);
            return(!domain.SequenceEqual(result));
        }
Esempio n. 2
0
        internal static Dictionary <MemberPath, Set <Constant> > ComputeConstantDomainSetsForSlotsInUpdateViews(
            IEnumerable <Cell> cells,
            EdmItemCollection edmItemCollection)
        {
            Dictionary <MemberPath, Set <Constant> > dictionary = new Dictionary <MemberPath, Set <Constant> >(MemberPath.EqualityComparer);

            foreach (Cell cell in cells)
            {
                CellQuery cquery = cell.CQuery;
                CellQuery squery = cell.SQuery;
                foreach (MemberProjectedSlot slot in squery.GetConjunctsFromWhereClause().Select <MemberRestriction, MemberProjectedSlot>((Func <MemberRestriction, MemberProjectedSlot>)(oneOfConst => oneOfConst.RestrictedMemberSlot)))
                {
                    Set <Constant> domain;
                    if (!Domain.GetRestrictedOrUnrestrictedDomain(slot, squery, edmItemCollection, out domain))
                    {
                        int projectedPosition = squery.GetProjectedPosition(slot);
                        if (projectedPosition >= 0 && !Domain.GetRestrictedOrUnrestrictedDomain(cquery.ProjectedSlotAt(projectedPosition) as MemberProjectedSlot, cquery, edmItemCollection, out domain))
                        {
                            continue;
                        }
                    }
                    MemberPath memberPath = slot.MemberPath;
                    Constant   defaultConstant;
                    if (Domain.TryGetDefaultValueForMemberPath(memberPath, out defaultConstant))
                    {
                        domain.Add(defaultConstant);
                    }
                    Set <Constant> set;
                    if (!dictionary.TryGetValue(memberPath, out set))
                    {
                        dictionary[memberPath] = domain;
                    }
                    else
                    {
                        set.AddRange((IEnumerable <Constant>)domain);
                    }
                }
            }
            return(dictionary);
        }
Esempio n. 3
0
        private static bool TryGetDomainRestrictedByWhereClause(
            IEnumerable <Constant> domain,
            MemberProjectedSlot slot,
            CellQuery cellQuery,
            out Set <Constant> result)
        {
            IEnumerable <Set <Constant> > source = cellQuery.GetConjunctsFromWhereClause().Where <MemberRestriction>((Func <MemberRestriction, bool>)(restriction => MemberPath.EqualityComparer.Equals(restriction.RestrictedMemberSlot.MemberPath, slot.MemberPath))).Select <MemberRestriction, Set <Constant> >((Func <MemberRestriction, Set <Constant> >)(restriction => new Set <Constant>(restriction.Domain.Values, Constant.EqualityComparer)));

            if (!source.Any <Set <Constant> >())
            {
                result = new Set <Constant>(domain);
                return(false);
            }
            Set <Constant> possibleValues = Domain.DeterminePossibleValues(source.SelectMany <Set <Constant>, Constant>((Func <Set <Constant>, IEnumerable <Constant> >)(m => m.Select <Constant, Constant>((Func <Constant, Constant>)(c => c)))), domain);
            Domain         domain1        = new Domain(domain, (IEnumerable <Constant>)possibleValues);

            foreach (Set <Constant> set in source)
            {
                domain1 = domain1.Intersect(new Domain((IEnumerable <Constant>)set, (IEnumerable <Constant>)possibleValues));
            }
            result = new Set <Constant>(domain1.Values, Constant.EqualityComparer);
            return(!domain.SequenceEqual <Constant>((IEnumerable <Constant>)result));
        }
Esempio n. 4
0
        // requires: domain not have any Negated constants other than NotNull
        // Also, cellQuery contains all final oneOfConsts or all partial oneOfConsts
        // cellquery must contain a whereclause of the form "True", "OneOfConst" or "
        // "OneOfConst AND ... AND OneOfConst"
        // slot must present in cellQuery and incomingDomain is the domain for it
        // effects: Returns the set of values that slot can take as restricted by cellQuery's whereClause
        private static bool TryGetDomainRestrictedByWhereClause(
            IEnumerable<Constant> domain, MemberProjectedSlot slot, CellQuery cellQuery, out CellConstantSet result)
        {
            var conditionsForSlot = cellQuery.GetConjunctsFromWhereClause()
                                             .Where(
                                                 restriction =>
                                                 MemberPath.EqualityComparer.Equals(
                                                     restriction.RestrictedMemberSlot.MemberPath, slot.MemberPath))
                                             .Select(
                                                 restriction => new CellConstantSet(restriction.Domain.Values, Constant.EqualityComparer));

            //Debug.Assert(!conditionsForSlot.Skip(1).Any(), "More than one Clause with the same path");

            if (!conditionsForSlot.Any())
            {
                // If the slot was not mentioned in the query return the domain without restricting it 
                result = new CellConstantSet(domain);
                return false;
            }

            // Now get all the possible values from domain and conditionValues
            var possibleValues = DeterminePossibleValues(conditionsForSlot.SelectMany(m => m.Select(c => c)), domain);

            var restrictedDomain = new Domain(domain, possibleValues);
            foreach (var conditionValues in conditionsForSlot)
            {
                // Domain derived from Edm-Type INTERSECTED with Conditions
                restrictedDomain = restrictedDomain.Intersect(new Domain(conditionValues, possibleValues));
            }

            result = new CellConstantSet(restrictedDomain.Values, Constant.EqualityComparer);
            return !domain.SequenceEqual(result);
        }
 internal IEnumerable <MemberRestriction> GetConjunctsFromOriginalWhereClause()
 {
     return(CellQuery.GetConjunctsFromWhereClause(this.m_originalWhereClause));
 }