Beispiel #1
0
        // effects: Given the fact that rightKeyConstraint is not implied by a
        // leftSide key constraint, return a useful error message -- some S
        // was not implied by the C key constraints
        internal static ErrorLog.Record GetErrorRecord(ViewKeyConstraint rightKeyConstraint)
        {
            var keySlots = new List <ViewCellSlot>(rightKeyConstraint.KeySlots);
            var table    = keySlots[0].SSlot.MemberPath.Extent;
            var cSet     = keySlots[0].CSlot.MemberPath.Extent;

            var tablePrefix = new MemberPath(table);
            var cSetPrefix  = new MemberPath(cSet);

            var       tableKey = ExtentKey.GetPrimaryKeyForEntityType(tablePrefix, (EntityType)table.ElementType);
            ExtentKey cSetKey  = null;

            if (cSet is EntitySet)
            {
                cSetKey = ExtentKey.GetPrimaryKeyForEntityType(cSetPrefix, (EntityType)cSet.ElementType);
            }
            else
            {
                cSetKey = ExtentKey.GetKeyForRelationType(cSetPrefix, (AssociationType)cSet.ElementType);
            }

            var message = Strings.ViewGen_KeyConstraint_Violation(
                table.Name,
                ViewCellSlot.SlotsToUserString(rightKeyConstraint.KeySlots, false /*isFromCside*/),
                tableKey.ToUserString(),
                cSet.Name,
                ViewCellSlot.SlotsToUserString(rightKeyConstraint.KeySlots, true /*isFromCside*/),
                cSetKey.ToUserString());

            var debugMessage = StringUtil.FormatInvariant("PROBLEM: Not implied {0}", rightKeyConstraint);

            return(new ErrorLog.Record(ViewGenErrorCode.KeyConstraintViolation, message, rightKeyConstraint.CellRelation.Cell, debugMessage));
        }
Beispiel #2
0
        internal static ErrorLog.Record GetErrorRecord(
            IEnumerable <ViewKeyConstraint> rightKeyConstraints)
        {
            ViewKeyConstraint viewKeyConstraint = (ViewKeyConstraint)null;
            StringBuilder     stringBuilder     = new StringBuilder();
            bool flag = true;

            foreach (ViewKeyConstraint rightKeyConstraint in rightKeyConstraints)
            {
                string userString = ViewCellSlot.SlotsToUserString((IEnumerable <ViewCellSlot>)rightKeyConstraint.KeySlots, true);
                if (!flag)
                {
                    stringBuilder.Append("; ");
                }
                flag = false;
                stringBuilder.Append(userString);
                viewKeyConstraint = rightKeyConstraint;
            }
            List <ViewCellSlot> viewCellSlotList = new List <ViewCellSlot>((IEnumerable <ViewCellSlot>)viewKeyConstraint.KeySlots);
            EntitySetBase       extent1          = viewCellSlotList[0].SSlot.MemberPath.Extent;
            EntitySetBase       extent2          = viewCellSlotList[0].CSlot.MemberPath.Extent;
            ExtentKey           keyForEntityType = ExtentKey.GetPrimaryKeyForEntityType(new MemberPath(extent1), (EntityType)extent1.ElementType);
            string message;

            if (extent2 is EntitySet)
            {
                message = Strings.ViewGen_KeyConstraint_Update_Violation_EntitySet((object)stringBuilder.ToString(), (object)extent2.Name, (object)keyForEntityType.ToUserString(), (object)extent1.Name);
            }
            else
            {
                AssociationEndMember shouldBeMappedToKey = Helper.GetEndThatShouldBeMappedToKey(((AssociationSet)extent2).ElementType);
                message = shouldBeMappedToKey == null?Strings.ViewGen_KeyConstraint_Update_Violation_AssociationSet((object)extent2.Name, (object)keyForEntityType.ToUserString(), (object)extent1.Name) : Strings.ViewGen_AssociationEndShouldBeMappedToKey((object)shouldBeMappedToKey.Name, (object)extent1.Name);
            }
            string debugMessage = StringUtil.FormatInvariant("PROBLEM: Not implied {0}", (object)viewKeyConstraint);

            return(new ErrorLog.Record(ViewGenErrorCode.KeyConstraintUpdateViolation, message, viewKeyConstraint.CellRelation.Cell, debugMessage));
        }
Beispiel #3
0
        internal static ErrorLog.Record GetErrorRecord(ViewKeyConstraint rightKeyConstraint)
        {
            List <ViewCellSlot> viewCellSlotList = new List <ViewCellSlot>((IEnumerable <ViewCellSlot>)rightKeyConstraint.KeySlots);
            EntitySetBase       extent1          = viewCellSlotList[0].SSlot.MemberPath.Extent;
            EntitySetBase       extent2          = viewCellSlotList[0].CSlot.MemberPath.Extent;
            MemberPath          prefix1          = new MemberPath(extent1);
            MemberPath          prefix2          = new MemberPath(extent2);
            ExtentKey           keyForEntityType = ExtentKey.GetPrimaryKeyForEntityType(prefix1, (EntityType)extent1.ElementType);
            ExtentKey           extentKey        = !(extent2 is EntitySet) ? ExtentKey.GetKeyForRelationType(prefix2, (AssociationType)extent2.ElementType) : ExtentKey.GetPrimaryKeyForEntityType(prefix2, (EntityType)extent2.ElementType);
            string message      = Strings.ViewGen_KeyConstraint_Violation((object)extent1.Name, (object)ViewCellSlot.SlotsToUserString((IEnumerable <ViewCellSlot>)rightKeyConstraint.KeySlots, false), (object)keyForEntityType.ToUserString(), (object)extent2.Name, (object)ViewCellSlot.SlotsToUserString((IEnumerable <ViewCellSlot>)rightKeyConstraint.KeySlots, true), (object)extentKey.ToUserString());
            string debugMessage = StringUtil.FormatInvariant("PROBLEM: Not implied {0}", (object)rightKeyConstraint);

            return(new ErrorLog.Record(ViewGenErrorCode.KeyConstraintViolation, message, rightKeyConstraint.CellRelation.Cell, debugMessage));
        }
Beispiel #4
0
        // effects: Given the fact that none of the rightKeyConstraint are not implied by a
        // leftSide key constraint, return a useful error message (used for
        // the Update requirement
        internal static ErrorLog.Record GetErrorRecord(IEnumerable <ViewKeyConstraint> rightKeyConstraints)
        {
            ViewKeyConstraint rightKeyConstraint = null;
            StringBuilder     keyBuilder         = new StringBuilder();
            bool isFirst = true;

            foreach (ViewKeyConstraint rightConstraint in rightKeyConstraints)
            {
                string keyMsg = ViewCellSlot.SlotsToUserString(rightConstraint.KeySlots, true /*isFromCside*/);
                if (isFirst == false)
                {
                    keyBuilder.Append("; ");
                }
                isFirst = false;
                keyBuilder.Append(keyMsg);
                rightKeyConstraint = rightConstraint;
            }

            List <ViewCellSlot> keySlots = new List <ViewCellSlot>(rightKeyConstraint.KeySlots);
            EntitySetBase       table    = keySlots[0].SSlot.MemberPath.Extent;
            EntitySetBase       cSet     = keySlots[0].CSlot.MemberPath.Extent;

            MemberPath tablePrefix = new MemberPath(table);
            ExtentKey  tableKey    = ExtentKey.GetPrimaryKeyForEntityType(tablePrefix, (EntityType)table.ElementType);

            string message;

            if (cSet is EntitySet)
            {
                message = System.Data.Entity.Strings.ViewGen_KeyConstraint_Update_Violation_EntitySet(keyBuilder.ToString(), cSet.Name,
                                                                                                      tableKey.ToUserString(), table.Name);
            }
            else
            {
                //For a 1:* or 0..1:* association, the * side has to be mapped to the
                //key properties of the table. Fior this specific case, we give out a specific message
                //that is specific for this case.
                AssociationSet       associationSet = (AssociationSet)cSet;
                AssociationEndMember endMember      = Helper.GetEndThatShouldBeMappedToKey(associationSet.ElementType);
                if (endMember != null)
                {
                    message = System.Data.Entity.Strings.ViewGen_AssociationEndShouldBeMappedToKey(endMember.Name,
                                                                                                   table.Name);
                }
                else
                {
                    message = System.Data.Entity.Strings.ViewGen_KeyConstraint_Update_Violation_AssociationSet(cSet.Name,
                                                                                                               tableKey.ToUserString(), table.Name);
                }
            }

            string debugMessage = StringUtil.FormatInvariant("PROBLEM: Not implied {0}", rightKeyConstraint);

            return(new ErrorLog.Record(true, ViewGenErrorCode.KeyConstraintUpdateViolation, message, rightKeyConstraint.CellRelation.Cell, debugMessage));
        }