/// <summary> /// 根据表名创建空Table /// </summary> /// <param name="p_tblName">表名</param> /// <returns></returns> public static Table Create(string p_tblName) { Throw.IfNullOrEmpty(p_tblName); Table tbl = new Table(); #if SERVER var schema = DbSchema.GetTableSchema(p_tblName); foreach (var col in schema.PrimaryKey.Concat(schema.Columns)) { tbl._columns.Add(new Column(col.Name, col.Type)); } #else foreach (var col in AtModel.EachColumns(p_tblName)) { tbl._columns.Add(new Column(col.ColName, GetColType(col.DbType))); } #endif return(tbl); }
internal static TableSchema GetTableSchema(string p_tblName) { TableSchema schema = new TableSchema(p_tblName.ToLower()); foreach (var oc in AtModel.EachColumns(p_tblName.ToLower())) { TableCol col = new TableCol(); col.Name = oc.ColName; col.Type = Table.GetColType(oc.DbType); col.Length = oc.Length; col.Nullable = oc.Nullable; col.Comments = oc.Comments; if (oc.IsPrimary) { schema.PrimaryKey.Add(col); } else { schema.Columns.Add(col); } } return(schema); }