示例#1
0
        public bool ColumnIsValid(IDataTableColumn column)
        {
            var _validColumns = GetValidColumns();

            if (_validColumns.Contains(column))
            {
                return(true);
            }
            return(false);
        }
        protected virtual string GetColumnFullType(string domain_name, string domain_schema, IDataTableColumn column)
        {
            // TODO: uncomment
            if (/* mmConfig.useDomainTypes && */domain_name != null)
                return domain_schema + "." + domain_name; //without precision - precision is already defined in CREATE DOMAIN

            if (column.Length != null)
                return column.SqlType + "(" + column.Length + ")";
            if (column.Precision != null && column.Scale != null)
                return column.SqlType + "(" + column.Precision + "," + column.Scale + ")";
            return column.SqlType;
        }
        /// <summary>
        /// 映射到与数据库无关的类型
        /// </summary>
        /// <param name="Column"></param>
        public void MapSimpleType(ref IDataTableColumn Column)
        {
            IDataType dt = new DataType();

            //公共字段
            dt.SimpleType = Column.SimpleType;
            //辅助字段
            dt.Type      = Column.Type;
            dt.Nullable  = Column.Nullable;
            dt.Length    = Column.Length;
            dt.Precision = Column.Precision;
            dt.Scale     = Column.Scale;
            dt.Unsigned  = Column.Unsigned;
            dt.FullType  = Column.FullType;

            Column.SimpleType = this.MapSimpleType(dt);
        }
        /// <summary>
        /// 根据表名获取表结构的完整信息(数据库无关)
        /// </summary>
        /// <param name="tablename"></param>
        /// <returns></returns>
        public Table getOneTableStruByTableName(string tablename)
        {
            Table tarTable = new Table();

            tarTable.TableName = tablename;
            IList <IDataTableColumn> cilist = this.m_handler.DbAdapter.GetSchemaHandler(m_handler).ReadColumns(tablename);
            List <DataTableColumn>   clist  = new List <DataTableColumn>();

            for (int i = 0; i < cilist.Count; i++)
            {
                DataTableColumn  dtc  = new DataTableColumn();
                IDataTableColumn idtc = cilist[i];

                dtc.ColumnName   = idtc.ColumnName;
                dtc.TableName    = idtc.TableName;
                dtc.TableSchema  = idtc.TableSchema;
                dtc.PrimaryKey   = idtc.PrimaryKey;
                dtc.DefaultValue = idtc.DefaultValue;
                dtc.Generated    = idtc.Generated;
                dtc.Comment      = idtc.Comment;

                dtc.SimpleType = idtc.SimpleType;
                dtc.Type       = idtc.Type;
                dtc.Nullable   = idtc.Nullable;
                dtc.Length     = idtc.Length;
                dtc.Precision  = idtc.Precision;
                dtc.Scale      = idtc.Scale;
                dtc.Unsigned   = idtc.Unsigned;
                dtc.FullType   = idtc.FullType;

                clist.Add(dtc);
            }

            for (int i = 0; i < clist.Count; i++)
            {
                IDataTableColumn idc = clist[i];
                this.MapSimpleType(ref idc);
            }
            tarTable.Columns = clist;
            return(tarTable);
        }
        protected virtual string GetFullType(IDataTableColumn column)
        {
            switch (column.SqlType.ToLower())
            {
            case "c":
            case "char":
            case "nchar":
            case "varchar":
            case "nvarchar":
            case "long varchar":
            case "text":
            case "integer":
                return column.SqlType + "(" + column.Length + ")";

            case "decimal":
                return column.SqlType + "(" + column.Length + ", " + column.Scale + ")";

            default:
                return column.SqlType;
            }
        }
示例#6
0
        protected virtual string GetFullType(IDataTableColumn column)
        {
            switch (column.SqlType.ToLower())
            {
            case "c":
            case "char":
            case "nchar":
            case "varchar":
            case "nvarchar":
            case "long varchar":
            case "text":
            case "integer":
                return(column.SqlType + "(" + column.Length + ")");

            case "decimal":
                return(column.SqlType + "(" + column.Length + ", " + column.Scale + ")");

            default:
                return(column.SqlType);
            }
        }
示例#7
0
 protected virtual string GetColumnFullType(string domain_name, string domain_schema, IDataTableColumn column)
 {
     // TODO: uncomment
     if (/* mmConfig.useDomainTypes && */ domain_name != null)
     {
         return(domain_schema + "." + domain_name); //without precision - precision is already defined in CREATE DOMAIN
     }
     if (column.Length != null)
     {
         return(column.SqlType + "(" + column.Length + ")");
     }
     if (column.Precision != null && column.Scale != null)
     {
         return(column.SqlType + "(" + column.Precision + "," + column.Scale + ")");
     }
     return(column.SqlType);
 }