internal ErrorLog.Record CheckForProjectedNotNullSlots(
            Cell sourceCell,
            IEnumerable <Cell> associationSets)
        {
            StringBuilder stringBuilder = new StringBuilder();
            bool          flag1         = false;

            foreach (MemberRestriction condition in this.Conditions)
            {
                if (condition.Domain.ContainsNotNull() && MemberProjectedSlot.GetSlotForMember((IEnumerable <ProjectedSlot>) this.m_projectedSlots, condition.RestrictedMemberSlot.MemberPath) == null)
                {
                    bool flag2 = true;
                    if (this.Extent is EntitySet)
                    {
                        bool       flag3       = sourceCell.CQuery == this;
                        ViewTarget target      = flag3 ? ViewTarget.QueryView : ViewTarget.UpdateView;
                        CellQuery  cellQuery   = flag3 ? sourceCell.SQuery : sourceCell.CQuery;
                        EntitySet  rightExtent = cellQuery.Extent as EntitySet;
                        if (rightExtent != null)
                        {
                            foreach (AssociationSet associationSet in MetadataHelper.GetAssociationsForEntitySet((EntitySetBase)(cellQuery.Extent as EntitySet)).Where <AssociationSet>((Func <AssociationSet, bool>)(association => association.AssociationSetEnds.Any <AssociationSetEnd>((Func <AssociationSetEnd, bool>)(end =>
                            {
                                if (end.CorrespondingAssociationEndMember.RelationshipMultiplicity == RelationshipMultiplicity.One)
                                {
                                    return(MetadataHelper.GetOppositeEnd(end).EntitySet.EdmEquals((MetadataItem)rightExtent));
                                }
                                return(false);
                            })))))
                            {
                                AssociationSet association = associationSet;
                                foreach (Cell cell in associationSets.Where <Cell>((Func <Cell, bool>)(c => c.GetRightQuery(target).Extent.EdmEquals((MetadataItem)association))))
                                {
                                    if (MemberProjectedSlot.GetSlotForMember((IEnumerable <ProjectedSlot>)cell.GetLeftQuery(target).ProjectedSlots, condition.RestrictedMemberSlot.MemberPath) != null)
                                    {
                                        flag2 = false;
                                    }
                                }
                            }
                        }
                    }
                    if (flag2)
                    {
                        stringBuilder.AppendLine(Strings.ViewGen_NotNull_No_Projected_Slot((object)condition.RestrictedMemberSlot.MemberPath.PathToString(new bool?(false))));
                        flag1 = true;
                    }
                }
            }
            if (!flag1)
            {
                return((ErrorLog.Record)null);
            }
            return(new ErrorLog.Record(ViewGenErrorCode.NotNullNoProjectedSlot, stringBuilder.ToString(), sourceCell, string.Empty));
        }
        internal static List <MemberProjectedSlot> GetSlots(
            IEnumerable <MemberProjectedSlot> slots,
            IEnumerable <MemberPath> members)
        {
            List <MemberProjectedSlot> memberProjectedSlotList = new List <MemberProjectedSlot>();

            foreach (MemberPath member in members)
            {
                MemberProjectedSlot slotForMember = MemberProjectedSlot.GetSlotForMember(Helpers.AsSuperTypeList <MemberProjectedSlot, ProjectedSlot>(slots), member);
                if (slotForMember == null)
                {
                    return((List <MemberProjectedSlot>)null);
                }
                memberProjectedSlotList.Add(slotForMember);
            }
            return(memberProjectedSlotList);
        }
Beispiel #3
0
        // requires: The Where clause satisfies the same requirements a GetConjunctsFromWhereClause
        // effects: For each slot that has a NotNull condition in the where
        // clause, checks if it is projected. If all such slots are
        // projected, returns null. Else returns an error record
        internal ErrorLog.Record CheckForProjectedNotNullSlots(Cell sourceCell, IEnumerable <Cell> associationSets)
        {
            var builder    = new StringBuilder();
            var foundError = false;

            foreach (var restriction in Conditions)
            {
                if (restriction.Domain.ContainsNotNull())
                {
                    var slot = MemberProjectedSlot.GetSlotForMember(m_projectedSlots, restriction.RestrictedMemberSlot.MemberPath);
                    if (slot == null) //member with not null condition is not mapped in this extent
                    {
                        var missingMapping = true;
                        if (Extent is EntitySet)
                        {
                            var isCQuery       = sourceCell.CQuery == this;
                            var target         = isCQuery ? ViewTarget.QueryView : ViewTarget.UpdateView;
                            var rightCellQuery = isCQuery ? sourceCell.SQuery : sourceCell.CQuery;

                            //Find out if there is an association mapping but only if the current Not Null condition is on an EntitySet
                            var rightExtent = rightCellQuery.Extent as EntitySet;
                            if (rightExtent != null)
                            {
                                var associations = MetadataHelper.GetAssociationsForEntitySet(rightCellQuery.Extent as EntitySet);
                                foreach (
                                    var association in
                                    associations.Where(
                                        association =>
                                        association.AssociationSetEnds.Any(
                                            end =>
                                            (end.CorrespondingAssociationEndMember.RelationshipMultiplicity
                                             == RelationshipMultiplicity.One &&
                                             (MetadataHelper.GetOppositeEnd(end).EntitySet.EdmEquals(rightExtent))))))
                                {
                                    foreach (
                                        var associationCell in
                                        associationSets.Where(c => c.GetRightQuery(target).Extent.EdmEquals(association)))
                                    {
                                        if (MemberProjectedSlot.GetSlotForMember(
                                                associationCell.GetLeftQuery(target).ProjectedSlots, restriction.RestrictedMemberSlot.MemberPath)
                                            != null)
                                        {
                                            missingMapping = false;
                                        }
                                    }
                                }
                            }
                        }

                        if (missingMapping)
                        {
                            // condition of NotNull and slot not being projected
                            builder.AppendLine(
                                Strings.ViewGen_NotNull_No_Projected_Slot(
                                    restriction.RestrictedMemberSlot.MemberPath.PathToString(false)));
                            foundError = true;
                        }
                    }
                }
            }
            if (false == foundError)
            {
                return(null);
            }
            var record = new ErrorLog.Record(ViewGenErrorCode.NotNullNoProjectedSlot, builder.ToString(), sourceCell, String.Empty);

            return(record);
        }