Beispiel #1
0
        private void InitializeColumnAttributeMapping(ColumnAttribute column)
        {
            this.name = string.IsNullOrEmpty(column.Name) ? this.memberInfo.Name : column.Name;

            if (column is KeyAttribute)
            {
                this.isPrimaryKey = true;

                this.key = (KeyAttribute)this.memberAttribute;

                this.isDbGenerated = this.isPrimaryKey && this.key.IsDbGenerated;

                this.sequenceName = this.key.SequenceName;
            }

            this.memberType = this.memberInfo.ReflectedType;
            this.dbType     = column.DbType;

            if (this.dbType == DBType.Char ||
                this.dbType == DBType.NChar ||
                this.dbType == DBType.NVarChar ||
                this.dbType == DBType.VarChar)
            {
                this.length = column.Length;
            }

            this.isNullable = this.isPrimaryKey ? false : column.IsNullable;
            this.isUnique   = this.isPrimaryKey ? true : column.IsUnique;

            if (column.IsVersion &&
                (this.dbType == DBType.Int16 ||
                 this.dbType == DBType.Int32 ||
                 this.dbType == DBType.Int64 ||
                 this.dbType == DBType.DateTime))
            {
                this.isVersion = true;
            }
            else
            {
                throw new MappingException(string.Format("Invalid Version member type '{0}' for  '{1}' , version type must be int or datetime type.",
                                                         this.dbType.ToString(),
                                                         this.entity.EntityType.Name + "." + this.memberInfo.Name));
            }

            this.updateCheck = column.UpdateCheck;
        }
Beispiel #2
0
        private void InitializeColumnAttributeMapping(ColumnAttribute column)
        {
            this.name = string.IsNullOrEmpty(column.Name) ? this.memberInfo.Name : column.Name;

            if (column is KeyAttribute)
            {
                this.isPrimaryKey = true;

                this.key = (KeyAttribute)this.memberAttribute;

                this.isDbGenerated = this.isPrimaryKey && this.key.IsDbGenerated;

                this.sequenceName = this.key.SequenceName;
            }

            this.memberType = this.memberInfo.ReflectedType;
            this.dbType = column.DbType;

            if (this.dbType == DBType.Char ||
                this.dbType == DBType.NChar ||
                this.dbType == DBType.NVarChar ||
                this.dbType == DBType.VarChar)
            {
                this.length = column.Length;
            }

            this.isNullable = this.isPrimaryKey ? false : column.IsNullable;
            this.isUnique = this.isPrimaryKey ? true : column.IsUnique;

            if (column.IsVersion &&
               (this.dbType == DBType.Int16 ||
                this.dbType == DBType.Int32 ||
                this.dbType == DBType.Int64 ||
                this.dbType == DBType.DateTime))
            {
                this.isVersion = true;
            }
            else
            {
                throw new MappingException(string.Format("Invalid Version member type '{0}' for  '{1}' , version type must be int or datetime type.", 
                                           this.dbType.ToString(),
                                           this.entity.EntityType.Name + "." + this.memberInfo.Name));
            }

            this.updateCheck = column.UpdateCheck;
        }