public static TableInfo GetTableInfo(this DataColumnCollection columns) { TableInfo res = new TableInfo(null); foreach (DataColumn col in columns.SortedByKey <DataColumn, int>(col => col.Ordinal)) { var commonType = TypeTool.GetCommonType(col.DataType); var colInfo = res.AddColumn(col.ColumnName, commonType.ToString(), TypeTool.GetCommonType(col.DataType)); colInfo.NotNull = !col.AllowDBNull; } return(res); }
public static ITableStructure GetTableStructure(this DataColumnCollection columns, string name) { TableStructure res = new TableStructure(); //res.FilledMembers |= TableStructureMembers.ColumnNames | TableStructureMembers.ColumnTypes; foreach (DataColumn col in columns.SortedByKey <DataColumn, int>(col => col.Ordinal)) { var c = res.AddColumn(col.ColumnName, TypeTool.GetDatAdminType(col.DataType)); c.IsNullable = col.AllowDBNull; c.DefaultValue = SqlExpression.ParseDefaultValue(col.DefaultValue.SafeToString(), null); } return(res); }