Beispiel #1
0
        internal static void ValidateTypedEntitySet(TypedEntitySet typedEntitySet, ValidationContext context)
        {
            TypedEntitySetHasItemType link = TypedEntitySetHasItemType.GetLinkToItemType(typedEntitySet);

            ValidationResult validationResult = TypedEntitySetHasItemTypeRules.Validate(link);

            context.LogErrorIfAny(validationResult);
        }
        public static void Connect(ModelElement sourceElement, ModelElement targetElement)
        {
            PersistentType sourceEntity = (PersistentType)sourceElement;
            PersistentType targetEntity = (PersistentType)targetElement;

            if (sourceEntity is TypedEntitySet && targetEntity is Interface)
            {
                TypedEntitySetHasItemType connection = new TypedEntitySetHasItemType((TypedEntitySet)sourceEntity, (Interface)targetEntity);

                if (DomainClassInfo.HasNameProperty(connection))
                {
                    DomainClassInfo.SetUniqueName(connection);
                }

                return;
            }

            IAssociationInfo sourceInfo = new AssociationInfo
            {
                Multiplicity   = MultiplicityKind.One,
                OnOwnerRemove  = AssociationOnRemoveAction.Default,
                OnTargetRemove = AssociationOnRemoveAction.Default
            };

            sourceInfo.PairTo.SetAsCustom(BuildNavigationPropertyName(sourceEntity, targetEntity, true));

            IAssociationInfo targetInfo = new AssociationInfo
            {
                Multiplicity   = MultiplicityKind.Many,
                OnOwnerRemove  = AssociationOnRemoveAction.Default,
                OnTargetRemove = AssociationOnRemoveAction.Default
            };

            targetInfo.PairTo.SetAsCustom(BuildNavigationPropertyName(sourceEntity, targetEntity, false));

            string associationName = BuildAssociationName(sourceEntity, targetEntity);

            CreatePersistentTypesAssociation(sourceElement, targetElement, sourceInfo, targetInfo, associationName,
                                             true, true);
        }