示例#1
0
        public DataTableColumn <TProperty> Add <TProperty>(Expression <Func <T, TProperty> > field)
        {
            var newField = new DataTableColumn <TProperty>(field);

            this.Columns.Add(newField);
            return(newField);
        }
示例#2
0
        public ValueTable(ТаблицаЗначений value)
        {
            if (value == null)
            {
                throw new System.ArgumentNullException("value");
            }

            this.Column = new DataTableColumn[value.Колонки.Count];
            for (int i = 0; i < value.Колонки.Count; i++)
            {
                DataTableColumn columnSOAP = new DataTableColumn();
                columnSOAP.Name = value.Колонки[i].Имя;
                this.Column[i]  = columnSOAP;
            }

            this.Row = new DataTableRow[value.Count];
            for (int i = 0; i < value.Count; i++)
            {
                DataTableRow rowSOAP = new DataTableRow();
                rowSOAP.Property = new ValueBase[value.Колонки.Count];

                for (int j = 0; j < value.Колонки.Count; j++)
                {
                    КолонкаКоллекцииЗначений column = value.Колонки[j];
                    ValueBase property = ValueBase.From(((dynamic)value[i]).GetByColumn(column));
                    property.Name       = column.Имя;
                    rowSOAP.Property[j] = property;
                }
                this.Row[i] = rowSOAP;
            }
        }
示例#3
0
 public CustomisationColumn(Int32 ordinal, DataTableColumn column)
 {
     _ordinal      = ordinal;
     _defaultTitle = column.Title;
     _exportable   = column.Exportable;
     _visible      = column.Visible;
 }
示例#4
0
        /// <summary>
        /// 获取单表的数据字段信息
        /// </summary>
        /// <param name="TableName">表名称</param>
        /// <returns></returns>
        public override IList <IDataTableColumn> ReadColumns(string TableName)
        {
            IList <IDataTableColumn> list = new List <IDataTableColumn>();

            IDataTableColumn Col = new DataTableColumn();

            Col.SimpleType = "0"; //默认的公共类型

            Col.ColumnName  = "字段名";
            Col.Nullable    = true;
            Col.TableName   = TableName;
            Col.TableSchema = TableName;
            Col.Type        = "类型";


            Col.Length    = 8;
            Col.Precision = 0;//整数长度
            Col.Scale     = 0;

            Col.FullType     = Col.Type;
            Col.DefaultValue = "默认值";

            Col.Comment = "注释";
            list.Add(Col);

            return(list);
        }
        protected virtual IDataTableColumn ReadColumn(IDataReader rdr)
        {
            var column = new DataTableColumn();
            int field  = 0;

            column.TableSchema = rdr.GetAsString(field++);
            column.TableName   = rdr.GetAsString(field++);
            column.ColumnName  = rdr.GetAsString(field++);
            string nullableStr = rdr.GetAsString(field++);

            column.Nullable = nullableStr == "YES";
            column.SqlType  = rdr.GetAsString(field++);
            var extra = rdr.GetAsString(field++);

            column.Generated = extra == "auto_increment";
            column.FullType  = FormatFullType(rdr.GetAsString(field++));
            column.Unsigned  = column.FullType.Contains("unsigned");
            string columnKey = rdr.GetAsString(field++);

            column.PrimaryKey   = columnKey == "PRI";
            column.Length       = rdr.GetAsNullableNumeric <long>(field++);
            column.Precision    = rdr.GetAsNullableNumeric <int>(field++);
            column.Scale        = rdr.GetAsNullableNumeric <int>(field++);
            column.DefaultValue = rdr.GetAsString(field++);
            return(column);
        }
示例#6
0
        protected virtual IDataTableColumn ReadColumn(IDataReader rdr)
        {
            var column = new DataTableColumn();
            int field  = 0;

            column.TableSchema = rdr.GetAsString(field++);
            column.TableName   = rdr.GetAsString(field++);
            column.ColumnName  = rdr.GetAsString(field++);
            string nullableStr = rdr.GetAsString(field++);

            column.Nullable = nullableStr == "YES";
            column.SqlType  = rdr.GetAsString(field++);
            var domain_schema = rdr.GetAsString(field++);
            var domain_name   = rdr.GetAsString(field++);

            column.DefaultValue = GetColumnDefaultValue(rdr.GetAsString(field++));
            column.Generated    = column.DefaultValue != null && column.DefaultValue.StartsWith("nextval(");

            column.Length    = rdr.GetAsNullableNumeric <long>(field++);
            column.Precision = rdr.GetAsNullableNumeric <int>(field++);
            column.Scale     = rdr.GetAsNullableNumeric <int>(field++);
            column.UdtName   = rdr.GetAsString(field++);

            column.FullType = GetColumnFullType(domain_name, domain_schema, column);

            return(column);
        }
示例#7
0
        /// <summary>
        /// 获取添加字段的sql语句
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public string GetAlterAddSqlOfColumnInfo(DataTableColumn field)
        {
            long?  len  = field.Length;
            string type = field.SimpleType;

            if (type.ToUpper().Equals("VARCHAR"))
            {
                type += "(" + len + ")";
            }
            if (field.DefaultValue != null && field.DefaultValue.Length > 0)
            {
                string defaultVal = field.DefaultValue;
                if (String.Compare(defaultVal, "(SYSDATE)", true) == 0)
                {
                    defaultVal = "(GETDATE())";
                }
                type += "  DEFAULT  " + defaultVal + "  ";
                if (field.Nullable)
                {
                    type += " null ";
                }
                else
                {
                    type += " not null ";
                }
            }
            if (field.Generated != null && (bool)field.Generated)
            {
                //type += "  UNIQUE  ";
            }
            return("ALTER TABLE " + field.TableName + " ADD " + field.ColumnName + " " + type);
        }
示例#8
0
 protected virtual void FillDataTableColumnInformation(DataRow row, DataTableColumn column)
 {
     if (column.PrimaryKey.HasValue && column.PrimaryKey.Value &&
         (column.ManagedType == "System.Int32" || column.ManagedType == "System.Int64"))
     {
         column.Generated = true;
     }
 }
示例#9
0
 /// <summary>
 /// 适应表结构字段到数据库类型
 /// </summary>
 /// <param name="tbl"></param>
 /// <param name="handler"></param>
 private void MapTableColToDbType(ref Table tbl, IDataBaseHandler handler)
 {
     for (int i = 0; i < tbl.Columns.Count; i++)
     {
         DataTableColumn dtc = tbl.Columns[i];
         handler.DbAdapter.GetSchemaHandler(handler).MapDBType(ref dtc);
     }
 }
示例#10
0
        public FilterRule(DataTableColumn <TModel> column, Type propertyType, string propertyName, ObjectFilter objectFilter)
        {
            Guid         = Guid.NewGuid();
            Column       = column;
            FilterType   = objectFilter;
            PropertyName = propertyName;

            UpdatePropertyType(propertyType);
        }
示例#11
0
        public Filter(DataTableColumn dataColumn)
        {
            this.WhenAnyValue(x => x.SelectedOperator, x => x.Value, (op, value) => FilterOperatorLookup.CreateFilterOperatorRule(op, value))
            .ToPropertyEx(this, x => x.SelectedFilterOperator, FilterOperatorLookup.CreateFilterOperatorRule(SelectedOperator, Value));

            DataColumn       = dataColumn;
            SelectedOperator = StringFilterOperator.Contains;
            Value            = string.Empty;
        }
示例#12
0
        private void AddFilter(DataTableColumn dataColumn)
        {
            if (dataColumn == placeholderColumn)
            {
                return;
            }

            Filters.Add(new Filter(dataColumn));
            SelectedAddColumn = placeholderColumn;
        }
示例#13
0
        /// <summary>
        /// 获取修改字段的sql语句
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public string GetAlterSqlOfColumnInfo(DataTableColumn field)
        {
            long?  len  = field.Length;
            string type = field.SimpleType;

            if (type.ToUpper().Equals("VARCHAR"))
            {
                type += "(" + len + ")";
            }
            //return "ALTER TABLE " + field.TableName + " alter column " + field.ColumnName + " " + type;
            return("");//不允许修改可删除字段,只能修改表名和添加字段
        }
示例#14
0
        protected virtual IDataTableColumn ReadColumn(IDataReader dataReader)
        {
            var column = new DataTableColumn();

            column.TableSchema = "main";
            column.TableName   = column.ColumnName = dataReader.GetString(0);
            column.ColumnName  = dataReader.GetString(1);
            column.UnpackRawDbType(dataReader.GetString(2));
            column.FullType = dataReader.GetString(2);
            column.Nullable = dataReader.GetString(3) != "NO";
            // SqlCe says: if it is a primary key of integer type, then it is automatically generated
            // column.Generated = column.PrimaryKey.Value && MapDbType(column.ColumnName, column) == typeof(int);
            return(column);
        }
示例#15
0
 protected virtual IDataTableColumn ReadColumn(IDataReader dataReader, string table)
 {
     var column = new DataTableColumn();
     column.TableSchema = "main";
     column.TableName = table;
     column.ColumnName = dataReader.GetString(1);
     column.UnpackRawDbType(dataReader.GetString(2));
     column.FullType = dataReader.GetString(2);
     column.Nullable = dataReader.GetInt64(3) == 0;
     column.PrimaryKey = dataReader.GetInt64(5) == 1;
     // SQLite says: if it is a primary key of integer type, then it is automatically generated
     column.Generated = column.PrimaryKey.Value && MapDbType(column.ColumnName, column) == typeof(int);
     return column;
 }
示例#16
0
        protected virtual IDataTableColumn ReadColumn(IDataReader dataReader, string table)
        {
            var column = new DataTableColumn();

            column.TableSchema = "main";
            column.TableName   = table;
            column.ColumnName  = dataReader.GetString(1);
            column.UnpackRawDbType(dataReader.GetString(2));
            column.FullType   = dataReader.GetString(2);
            column.Nullable   = dataReader.GetInt64(3) == 0;
            column.PrimaryKey = dataReader.GetInt64(5) == 1;
            // SQLite says: if it is a primary key of integer type, then it is automatically generated
            column.Generated = column.PrimaryKey.Value && MapDbType(column.ColumnName, column) == typeof(int);
            return(column);
        }
示例#17
0
 /// <summary>
 /// 根据表结构文档生成此连接下表结构Sql语句(无协调功能)
 /// </summary>
 /// <param name="handler"></param>
 /// <returns></returns>
 public string GetFixTableStuSqlByFile2(IDataBaseHandler handler)
 {
     for (int i = 0; i < this.List.Count; i++)
     {
         Table tbl = (Table)this.List[i];
         List <DataTableColumn> dtcl = tbl.Columns;
         for (int j = 0; j < dtcl.Count; j++)
         {
             DataTableColumn dtc = dtcl[j];
             //映射到当前的数据库类型下
             handler.DbAdapter.GetSchemaHandler(handler).MapDBType(ref dtc);
         }
     }
     //相当于全部以新的不存在的数据表添加进去
     return(handler.DbAdapter.GetSchemaHandler(handler).GetDbServerScript(this.List));
 }
 protected virtual IDataTableColumn ReadColumn(IDataReader rdr)
 {
     var column = new DataTableColumn();
     int field = 0;
     column.TableSchema = rdr.GetString(field++);
     column.TableName = rdr.GetString(field++);
     column.ColumnName = rdr.GetString(field++);
     column.SqlType = rdr.GetString(field++);
     column.Length = rdr.GetAsNullableNumeric<long>(field++);
     column.Precision = rdr.GetAsNullableNumeric<int>(field++);
     column.Scale = rdr.GetAsNullableNumeric<int>(field++);
     string nullableStr = rdr.GetString(field++);
     column.Nullable = nullableStr == "Y";
     column.FullType = column.SqlType;
     return column;
 }
        private static List <DataTableColumn> GetDataTableColumns(IEnumerable <EdmProperty> properties, DataTableColumn parentColumn)
        {
            var columns = new List <DataTableColumn>();

            foreach (var property in properties)
            {
                Type type = null;

                var primitiveType = property.TypeUsage.EdmType as PrimitiveType;
                if (primitiveType != null)
                {
                    type = primitiveType.ClrEquivalentType;
                }
                else if (property.TypeUsage.EdmType as SimpleType != null)
                {
                    type = typeof(int);
                }

                var columnName = parentColumn != null ? parentColumn.ColumnName + "_" + property.Name : property.Name;
                var column     = new DataTableColumn
                {
                    ColumnName   = columnName,
                    PropertyName = property.Name,
                    ParentColumn = parentColumn,
                    Type         = type
                };

                if (column.Type != null)
                {
                    columns.Add(column);
                }
                else
                {
                    var complexType = property.TypeUsage.EdmType as ComplexType;
                    if (complexType != null)
                    {
                        columns.AddRange(GetDataTableColumns(complexType.Properties, column));
                    }
                    else
                    {
                        throw new NotSupportedException(string.Format("The EdmType '{0}' is not supported.", property.TypeUsage.EdmType.FullName));
                    }
                }
            }

            return(columns);
        }
示例#20
0
 private void SetItems(Type type, List <string> parents)
 {
     foreach (var item in ModelProvider.Instance.GetItems(type))
     {
         var parentsAndCurrent = new List <string>();
         parentsAndCurrent.AddRange(parents);
         parentsAndCurrent.Add(item.Name);
         if (item.Expansion)
         {
             SetItems(item.Property.PropertyType, parentsAndCurrent);
             continue;
         }
         var itemName = string.Join("-", parentsAndCurrent);
         var column   = new DataTableColumn(itemName, item.Property, item.Display, item.Property != PrimaryKeyProperty && !item.Hidden);
         Columns.Add(itemName, column);
     }
 }
示例#21
0
        /// <summary>
        ///     Adds the columns to the grid and defines the data source for restful searching
        /// </summary>
        private void InitialiseResult()
        {
            IEnumerable <SearchColumn> searchColumns = this.SearchType.Columns.OfType <SearchColumn>().OrderBy(col => col.Order);

            foreach (SearchColumn column in searchColumns)
            {
                DataTableColumn tableColumn = this.InitialiseResult(column);
                if (tableColumn != null)
                {
                    tableColumn.Title      = column.Label;
                    tableColumn.Tooltip    = column.ToolTip;
                    tableColumn.Visible    = column.Visible && (column.ShowInBasicResults || !this.BasicResult) && ((column.OutputType & SearchColumnOutputTypes.Screen) == SearchColumnOutputTypes.Screen);
                    tableColumn.Exportable = ((column.OutputType & SearchColumnOutputTypes.Export) == SearchColumnOutputTypes.Export);
                    this.SearchResult.Columns.Add(tableColumn);
                }
            }
        }
示例#22
0
        public IList <Draco.DB.QuickDataBase.Schema.Vendor.IDataTableColumn> ReadColumns(string TableName)
        {
            string  SQL = String.Format("PRAGMA table_info('{0}')", TableName);
            DataSet ds  = m_Handler.ExecuteQuery(SQL);

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                IList <IDataTableColumn> list = new List <IDataTableColumn>();
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    IDataTableColumn Col = new DataTableColumn();
                    Col.SimpleType = "0"; //默认的公共类型

                    Col.ColumnName  = Convert.ToString(row["name"]);
                    Col.Nullable    = Convert.ToInt32(row["notnull"]) == 0;
                    Col.TableName   = TableName;
                    Col.TableSchema = TableName;
                    if (Convert.ToInt32(row["pk"]) == 1)//主键
                    {
                        Col.PrimaryKey = true;
                    }
                    Col.DefaultValue = Convert.ToString(row["dflt_value"]); //缺省值
                    string DType = Convert.ToString(row["type"]);
                    if (DType.Contains("("))                                //VARCHAR和NVARCHAR类型是包含数据长度的
                    {
                        int      LeftBracket      = DType.IndexOf("(");
                        int      RightBracket     = DType.IndexOf(")");
                        string   sLen             = DType.Substring(LeftBracket + 1, RightBracket - LeftBracket - 1);//取出长度
                        String[] sLenAndPrecision = sLen.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        Col.Length = Convert.ToInt32(sLenAndPrecision[0]);
                        if (sLenAndPrecision.Length > 1)//除了长度,还有精度
                        {
                            Col.Precision = Convert.ToInt32(sLenAndPrecision[1]);
                        }
                        DType = DType.Substring(0, LeftBracket);
                    }
                    Col.Type     = DType;
                    Col.FullType = Col.Type;

                    list.Add(Col);
                }
                return(list);
            }
            return(null);
        }
示例#23
0
        public ValueTree(ДеревоЗначений value)
        {
            if (value == null)
            {
                throw new System.ArgumentNullException("value");
            }

            this.Column = new DataTableColumn[value.Колонки.Count];
            for (int i = 0; i < value.Колонки.Count; i++)
            {
                DataTableColumn columnSOAP = new DataTableColumn();
                columnSOAP.Name = value.Колонки[i].Имя;
                this.Column[i]  = columnSOAP;
            }

            this.Row = new DataTableRow[value.Строки().Count];
            this.AddRowsSOAP(value, this.Row, value.Строки());
        }
示例#24
0
 /// <summary>
 /// 确认填充ADOType值
 /// </summary>
 /// <param name="schema"></param>
 public void EnSureADOType(Database schema)
 {
     if (schema != null && schema.Tables != null)
     {
         foreach (var tbl in schema.Tables)
         {
             if (tbl.Type.Columns != null)
             {
                 foreach (var Col in tbl.Type.Columns)
                 {
                     var Column = new DataTableColumn();
                     Column.Type = Col.DbType;
                     Col.ADOType = MapAdoType(Column);
                 }
             }
         }
     }
 }
 /// <summary>
 /// Retrieve DataTable parameters from JSON, sanitized against parameter spoofing
 /// </summary>
 /// <param name="input">JToken object</param>
 /// <returns>parameters</returns>
 public static DataTableParameters Get(JToken input)
 {
     return(new DataTableParameters
     {
         Columns = DataTableColumn.Get(input),
         Order = DataTableOrder.Get(input),
         Draw = (int)input["draw"],
         Start = (int)input["start"],
         Length = (int)input["length"],
         SearchValue =
             new string(
                 ((string)input["search"]["value"]).Where(
                     c => char.IsLetterOrDigit(c) || char.IsWhiteSpace(c) || c == '-').ToArray()),
         SearchRegex = (bool)input["search"]["regex"],
         _WebPartID = (string)input["webpartid"],
         _PageUrl = (string)input["pageurl"]
     });
 }
        protected virtual IDataTableColumn ReadColumn(IDataReader rdr)
        {
            var column = new DataTableColumn();
            int field  = 0;

            column.TableSchema = rdr.GetString(field++);
            column.TableName   = rdr.GetString(field++);
            column.ColumnName  = rdr.GetString(field++);
            column.SqlType     = rdr.GetString(field++);
            column.Length      = rdr.GetAsNullableNumeric <long>(field++);
            column.Precision   = rdr.GetAsNullableNumeric <int>(field++);
            column.Scale       = rdr.GetAsNullableNumeric <int>(field++);
            string nullableStr = rdr.GetString(field++);

            column.Nullable = nullableStr == "Y";
            column.FullType = column.SqlType;
            return(column);
        }
        protected virtual IDataTableColumn ReadColumn(IDataRecord rdr)
        {
            var column = new DataTableColumn();
            int field = 0;
            column.TableSchema = rdr.GetAsString(field++).Trim();
            column.TableName = rdr.GetAsString(field++).Trim();
            column.ColumnName = rdr.GetAsString(field++).Trim();
            string nullableStr = rdr.GetAsString(field++);
            column.Nullable = nullableStr == "Y";
            column.SqlType = rdr.GetAsString(field++).Trim();
            column.DefaultValue = rdr.GetAsString(field++);
            column.Generated = column.DefaultValue != null && column.DefaultValue.StartsWith("next value for");

            column.Length = rdr.GetAsNullableNumeric<long>(field++);
            column.Scale = rdr.GetAsNullableNumeric<int>(field++);
            column.FullType = GetFullType(column);
            return column;
        }
示例#28
0
        /// <summary>
        /// 获取修改字段的sql语句
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public string GetAlterSqlOfColumnInfo(DataTableColumn field)
        {
            long?  len  = field.Length;
            string type = field.SimpleType;

            if (type.ToUpper().Equals("VARCHAR2"))
            {
                type += "(" + len + ")";
            }
            if (type.ToUpper().Equals("NUMBER"))
            {
                if (field.Scale > 0)
                {
                    type += "(" + field.Precision + "," + field.Scale + ")";
                }
            }
            return("ALTER TABLE " + field.TableName + " MODIFY( " + field.ColumnName + " " + type + ")");
        }
        /// <summary>
        /// 获取单表的数据字段信息
        /// </summary>
        /// <param name="TableName">表名称</param>
        /// <returns></returns>
        public virtual IList <IDataTableColumn> ReadColumns(string TableName)
        {
            string    SQL = String.Format(SelectFieldSQL, TableName);
            DataSet   ds  = m_DBHelper.ExecuteQuery(SQL);
            Hashtable hs  = GetColumnComment(TableName);

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                IList <IDataTableColumn> list = new List <IDataTableColumn>();
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    IDataTableColumn Col = new DataTableColumn();
                    Col.SimpleType = "0"; //默认的公共类型

                    Col.ColumnName  = Convert.ToString(row["字段名"]);
                    Col.Nullable    = !String.IsNullOrEmpty(Convert.ToString(row["允许空"]));
                    Col.TableName   = TableName;
                    Col.TableSchema = TableName;
                    Col.Type        = Convert.ToString(row["类型"]);
                    if (!String.IsNullOrEmpty(Convert.ToString(row["主键"])))
                    {
                        Col.PrimaryKey = true;
                    }
                    if (!String.IsNullOrEmpty(Convert.ToString(row["标识"])))
                    {
                        Col.Generated = true;
                    }

                    Col.Length    = Convert.ToInt32(row["长度"]);
                    Col.Precision = Convert.ToInt32(row["长度"]);//整数长度
                    Col.Scale     = Convert.ToInt32(row["小数位数"]);

                    Col.FullType     = Col.Type;
                    Col.DefaultValue = Convert.ToString(row["默认值"]);
                    if (hs != null && hs[Col.ColumnName] != null)//注释
                    {
                        Col.Comment = hs[Col.ColumnName].ToString();
                    }
                    list.Add(Col);
                }
                return(list);
            }
            return(null);
        }
 protected virtual IDataTableColumn ReadColumn(IDataReader rdr)
 {
     var column = new DataTableColumn();
     int field = 0;
     column.TableSchema = rdr.GetAsString(field++);
     column.TableName = rdr.GetAsString(field++).Trim();
     column.ColumnName = rdr.GetAsString(field++).Trim();
     column.Nullable = rdr.GetAsBool(field++);
     column.SqlType = rdr.GetAsString(field++).Trim();
     column.Generated = rdr.GetAsBool(field++);
     //column.Unsigned = column.FullType.Contains("unsigned");
     column.PrimaryKey = rdr.GetAsBool(field++);
     column.Length = rdr.GetAsNullableNumeric<long>(field++);
     column.Precision = rdr.GetAsNullableNumeric<int>(field++);
     column.Scale = rdr.GetAsNullableNumeric<int>(field++);
     column.DefaultValue = rdr.GetAsString(field++);
     FormatFullType(column);
     return column;
 }
示例#31
0
        protected virtual IDataTableColumn ReadColumn(IDataRecord rdr)
        {
            var column = new DataTableColumn();
            int field  = 0;

            column.TableSchema = rdr.GetAsString(field++).Trim();
            column.TableName   = rdr.GetAsString(field++).Trim();
            column.ColumnName  = rdr.GetAsString(field++).Trim();
            string nullableStr = rdr.GetAsString(field++);

            column.Nullable     = nullableStr == "Y";
            column.SqlType      = rdr.GetAsString(field++).Trim();
            column.DefaultValue = rdr.GetAsString(field++);
            column.Generated    = column.DefaultValue != null && column.DefaultValue.StartsWith("next value for");

            column.Length   = rdr.GetAsNullableNumeric <long>(field++);
            column.Scale    = rdr.GetAsNullableNumeric <int>(field++);
            column.FullType = GetFullType(column);
            return(column);
        }
        protected virtual IDataTableColumn ReadColumn(IDataReader rdr)
        {
            var column = new DataTableColumn();
            int field  = 0;

            column.TableSchema = rdr.GetAsString(field++);
            column.TableName   = rdr.GetAsString(field++).Trim();
            column.ColumnName  = rdr.GetAsString(field++).Trim();
            column.Nullable    = rdr.GetAsBool(field++);
            column.SqlType     = rdr.GetAsString(field++).Trim();
            column.Generated   = rdr.GetAsBool(field++);
            //column.Unsigned = column.FullType.Contains("unsigned");
            column.PrimaryKey   = rdr.GetAsBool(field++);
            column.Length       = rdr.GetAsNullableNumeric <long>(field++);
            column.Precision    = rdr.GetAsNullableNumeric <int>(field++);
            column.Scale        = rdr.GetAsNullableNumeric <int>(field++);
            column.DefaultValue = rdr.GetAsString(field++);
            FormatFullType(column);
            return(column);
        }
        /// <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 IDataTableColumn ReadColumn(IDataReader rdr)
 {
     var column = new DataTableColumn();
     int field = 0;
     column.TableSchema = rdr.GetAsString(field++);
     column.TableName = rdr.GetAsString(field++);
     column.ColumnName = rdr.GetAsString(field++);
     string nullableStr = rdr.GetAsString(field++);
     column.Nullable = nullableStr == "YES";
     column.SqlType = rdr.GetAsString(field++);
     var extra = rdr.GetAsString(field++); 
     column.Generated = extra == "auto_increment";
     column.FullType = FormatFullType(rdr.GetAsString(field++));
     column.Unsigned = column.FullType.Contains("unsigned");
     string columnKey = rdr.GetAsString(field++);
     column.PrimaryKey = columnKey == "PRI";
     column.Length = rdr.GetAsNullableNumeric<long>(field++);
     column.Precision = rdr.GetAsNullableNumeric<int>(field++);
     column.Scale = rdr.GetAsNullableNumeric<int>(field++);
     column.DefaultValue = rdr.GetAsString(field++);
     return column;
 }
示例#35
0
        protected virtual IDataTableColumn ReadColumn(IDataReader rdr)
        {
            var column = new DataTableColumn();
            int field = 0;
            column.TableSchema = rdr.GetAsString(field++);
            column.TableName = rdr.GetAsString(field++);
            column.ColumnName = rdr.GetAsString(field++);
            string nullableStr = rdr.GetAsString(field++);
            column.Nullable = nullableStr == "YES";
            column.SqlType = rdr.GetAsString(field++);
            var domain_schema = rdr.GetAsString(field++);
            var domain_name = rdr.GetAsString(field++);
            column.DefaultValue = GetColumnDefaultValue(rdr.GetAsString(field++));
            column.Generated = column.DefaultValue != null && column.DefaultValue.StartsWith("nextval(");

            column.Length = rdr.GetAsNullableNumeric<long>(field++);
            column.Precision = rdr.GetAsNullableNumeric<int>(field++);
            column.Scale = rdr.GetAsNullableNumeric<int>(field++);

            column.FullType = GetColumnFullType(domain_name, domain_schema, column);

            return column;
        }
示例#36
0
            public DataTableColumn GetValue(ModelBindingContext context)
            {
                var modelname = context.ModelName;

                var model = new DataTableColumn();

                model.Data = DataTableBinderProvider.GetValue(context, $"{ modelname }[data]");
                model.Name = DataTableBinderProvider.GetValue(context, $"{ modelname }[name]");
                if (bool.TryParse(DataTableBinderProvider.GetValue(context, $"{ modelname }[searchable]"), out bool seachable))
                {
                    model.Searchable = seachable;
                }
                if (bool.TryParse(DataTableBinderProvider.GetValue(context, $"{ modelname }[orderable]"), out bool orderable))
                {
                    model.Orderable = orderable;
                }
                model.Search       = new DataTableColumnSearch();
                model.Search.Value = DataTableBinderProvider.GetValue(context, $"{ modelname }[search][value]");
                if (bool.TryParse(DataTableBinderProvider.GetValue(context, $"{ modelname }[search][regex]"), out bool regex))
                {
                    model.Search.Regex = regex;
                }
                return(model);
            }
 private void FormatFullType(DataTableColumn column)
 {
     // TODO: Implement.
 }