Ejemplo n.º 1
0
        // Methods
        internal AttributedMetaDataMember(AttributedMetaType metaType, MemberInfo mi, int ordinal)
        {
            this.declaringType  = mi.DeclaringType;
            this.metaType       = metaType;
            this.member         = mi;
            this.ordinal        = ordinal;
            this.type           = TypeSystem.GetMemberType(mi);
            this.isNullableType = TypeSystem.IsNullableType(this.type);

            this.attributeProvider = this.MetaModel.AttributeProvider;

            /*
             * this.attrColumn = (ColumnAttribute)Attribute.GetCustomAttribute(mi, typeof(ColumnAttribute));
             * this.attrAssoc = (AssociationAttribute)Attribute.GetCustomAttribute(mi, typeof(AssociationAttribute));
             */
            this.attrColumn = attributeProvider.GetColumnAttribute(mi);
            this.attrAssoc  = attributeProvider.GetAssociationAttribute(mi);

            this.attr = (this.attrColumn != null) ? ((DataAttribute)attrColumn) : this.attrAssoc;
            if (attr != null && attr.Storage != null)
            {
                MemberInfo[] member = mi.DeclaringType.GetMember(this.attr.Storage, BindingFlags.NonPublic | BindingFlags.Instance);
                if (member == null || member.Length != 1)
                {
                    throw Mapping.Error.BadStorageProperty(this.attr.Storage, mi.DeclaringType, mi.Name);
                }
                this.storageMember = member[0];
            }
            Type entityType = (this.storageMember != null) ? TypeSystem.GetMemberType(this.storageMember) : this.type;

            this.isDeferred = this.IsDeferredType(entityType);
            if ((this.attrColumn != null && this.attrColumn.IsDbGenerated) &&
                (this.attrColumn.IsPrimaryKey && this.attrColumn.AutoSync != AutoSync.Default) &&
                (this.attrColumn.AutoSync != AutoSync.OnInsert))
            {
                throw Mapping.Error.IncorrectAutoSyncSpecification(mi.Name);
            }
        }