Exemple #1
0
        public bool Match(MemberInfo subject)
        {
            var  propertyType = subject.GetPropertyOrFieldType();
            Type many         = propertyType.DetermineCollectionElementType();

            Type one = subject.DeclaringType;

            if (many == null)
            {
                return(false);
            }
            if (one.Equals(many))
            {
                // Circular references
                return(false);
            }
            CascadeOn?applyCascade = DomainInspector.ApplyCascade(one, subject, many);

            if (applyCascade.HasValue && !applyCascade.Value.Has(CascadeOn.DeleteOrphans) &&
                !applyCascade.Value.Has(CascadeOn.Remove) && !applyCascade.Value.Has(CascadeOn.All))
            {
                return(false);
            }
            if (!DomainInspector.IsEntity(many))
            {
                return(false);
            }
            if (DomainInspector.IsTablePerClass(many) && !DomainInspector.IsRootEntity(many))
            {
                return(false);
            }
            return(base.Match(new Relation(one, many)));
        }
Exemple #2
0
        public override bool Match(MemberInfo subject)
        {
            if (!base.Match(subject))
            {
                return(false);
            }

            var concreteRelation = GetConcreteRelation(subject);

            if (concreteRelation == null)
            {
                return(false);
            }
            var one  = concreteRelation.From;
            var many = concreteRelation.To;

            if (one.Equals(many))
            {
                // Circular references
                return(false);
            }

            Cascade?applyCascade = GetExplicitPolymorphismCascade(subject);

            if (applyCascade.HasValue && !applyCascade.Value.Has(Cascade.DeleteOrphans) &&
                !applyCascade.Value.Has(Cascade.Remove) && !applyCascade.Value.Has(Cascade.All))
            {
                return(false);
            }
            if (!DomainInspector.IsEntity(many))
            {
                return(false);
            }
            if (DomainInspector.IsTablePerClass(many) && !DomainInspector.IsRootEntity(many))
            {
                return(false);
            }

            return(true);
        }