// 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)); }
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)); }