Esempio n. 1
0
        private void InitializeAssociationAttributeMapping(AssociationAttribute association, bool isEnumerableType)
        {
            this.isForeignKey = association.IsForeignKey;

            if (this.isForeignKey ||
                association is ManyToOneAttribute)
            {
                this.isManyToOne = true;
            }

            if (isEnumerableType)
            {
                this.relatedType = ReflectionHelper.GetElementType(this.MemberType);
            }
            else
            {
                this.relatedType = this.memberType;
            }

            var tableAttribute = this.relatedType.GetCustomAttributes <TableAttribute>().FirstOrDefault();

            string thisKey  = association.ThisKey;
            string otherKey = association.OtherKey;

            this.relatedEntity = new EntityMapping(tableAttribute.Name, this.relatedType, null);

            this.thisKeyMembers = thisKey.Split(separators).Select(m => GetMemberMapping(this.Entity.EntityType, m, this.entity)).ToArray();

            this.otherKeyMembers = this.relatedEntity.PrimaryKeys;
        }
Esempio n. 2
0
        private void InitializeAssociationAttributeMapping(AssociationAttribute association, bool isEnumerableType)
        {
            this.isForeignKey = association.IsForeignKey;

            if (this.isForeignKey || 
                association is ManyToOneAttribute)
            {
                this.isManyToOne = true;
            }

            if (isEnumerableType)
            {
                this.relatedType = ReflectionHelper.GetElementType(this.MemberType);
            }
            else
            {
                this.relatedType = this.memberType;
            }

            var tableAttribute = this.relatedType.GetCustomAttributes<TableAttribute>().FirstOrDefault();

            string thisKey = association.ThisKey;
            string otherKey = association.OtherKey;

            this.relatedEntity = new EntityMapping(tableAttribute.Name, this.relatedType, null);

            this.thisKeyMembers = thisKey.Split(separators).Select(m => GetMemberMapping(this.Entity.EntityType, m, this.entity)).ToArray();

            this.otherKeyMembers = this.relatedEntity.PrimaryKeys;
        }