예제 #1
0
        private SqlMetaData GetSqlMetadaFromType(DmColumn column)
        {
            SqlMetaData smd = null;

            var sqlDbType = column.GetSqlDbType();
            var dbType    = column.DbType;
            var precision = column.GetSqlTypePrecision();
            int maxLength = column.MaxLength;

            if (sqlDbType == SqlDbType.VarChar || sqlDbType == SqlDbType.NVarChar)
            {
                maxLength = column.MaxLength <= 0 ? ((sqlDbType == SqlDbType.NVarChar) ? 4000 : 8000) : column.MaxLength;
                return(new SqlMetaData(column.ColumnName, sqlDbType, maxLength));
            }

            if (column.DataType == typeof(char))
            {
                return(new SqlMetaData(column.ColumnName, sqlDbType, 1));
            }

            smd = new SqlMetaData(column.ColumnName, sqlDbType);

            return(smd);
        }