示例#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)));
        }
        public override bool Match(MemberInfo subject)
        {
            var relation = GetRelation(subject);

            if (relation == null || !DomainInspector.IsEntity(relation.To))
            {
                return(false);
            }

            return(base.Match(subject));
        }
示例#3
0
        protected virtual string GetColumnNameForRelation(PropertyPath subject)
        {
            var relation = GetRelation(subject.LocalMember);
            var fromMany = relation.From;

            if (!DomainInspector.IsEntity(fromMany))
            {
                fromMany = subject.GetContainerEntity(DomainInspector);
            }
            var toMany         = relation.To;
            var baseColumnName = toMany.GetPoidColumnName();

            return(fromMany != toMany ? baseColumnName : string.Format("{0}_{1}", subject.ToColumnName("_"), baseColumnName));
        }
示例#4
0
        protected virtual string GetColumnNameForRelation(PropertyPath subject)
        {
            var relation = GetRelation(subject.LocalMember);
            var fromMany = relation.From;

            if (!DomainInspector.IsEntity(fromMany))
            {
                fromMany = subject.GetContainerEntity(DomainInspector);
            }
            var toMany         = relation.To;
            var baseColumnName = toMany.Name + "Id";

            if (fromMany != toMany)
            {
                return(baseColumnName);
            }
            return(subject.ToColumnName() + baseColumnName);
        }
示例#5
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);
        }