private static void BuildFields(DataSourceSchema schema) { DsAdapterCustomer dsa = new DsAdapterCustomer(schema); DataSet ds = dsa.getDataSet(); DataTable netTable = ds.Tables[0]; // schema.Fields.Clear(); SchemaList <FieldSchema> tmpFieldSchema = new SchemaList <FieldSchema>(); //da.FillSchema(netTable, SchemaType.Source); // schema.PrimaryKeys = new List<string>(); // foreach (DataColumn col in netTable.PrimaryKey) // { // schema.PrimaryKeys.Add(col.ColumnName); // } foreach (DataColumn col in netTable.Columns) { FieldSchema field = new FieldSchema(); field.Id = col.ColumnName; field.Title = col.Caption; if (col.ExtendedProperties.ContainsKey(DataSourceConst.ExProDescription)) { if (col.ExtendedProperties[DataSourceConst.ExProDescription] != null) { field.Description = col.ExtendedProperties[DataSourceConst.ExProDescription].ToString(); } } field.ReadOnly = col.ReadOnly; field.ReadOnly = col.AutoIncrement; if (netTable.PrimaryKey.Contains(col)) { field.IsKey = true; } if (col.ExtendedProperties.ContainsKey(DataSourceConst.ExProDbType)) { field.DataType = (DbType)col.ExtendedProperties[DataSourceConst.ExProDbType]; } else { field.DataType = DatabaseAdmin.getInstance().getDbType(col.DataType); } // schema.Fields.Add(field); if (schema.Fields.FindItem(field.Id) == null) { schema.Fields.Add(field); } if (tmpFieldSchema.FindItem(field.Id) == null) { tmpFieldSchema.Add(field); } } }
public DataSet getDataSet() { if (_ds != null) { return(_ds); } string where = getWhere(); string orderBy = getOrderBy(); string groupBy = null; DsAdapterCustomer dsa = new DsAdapterCustomer(_schema); return(dsa.getDataSet(getQueryParams(_schema.SelectCommand), where, orderBy, groupBy, _pagination)); }
public ListDataRow row(Dictionary <string, string> pk) { if (pk == null || pk.Count < 1) { throw new Exception(Lang.UpdateNoKey); } StringBuilder sb = new StringBuilder(); foreach (string field in pk.Keys) { sb.Append(" and "); sb.Append(field); sb.Append("='"); sb.Append(pk[field]); sb.Append("' "); } sb.Remove(0, 5); PaginationInfo pagin = new PaginationInfo(); DsAdapterCustomer dsa = new DsAdapterCustomer(_schema); DataSet ds = dsa.getDataSet(getQueryParams(_schema.SelectCommand), sb.ToString(), null, null, pagin); if (ds.Tables.Count < 1) { return(null); } DataTable tb = ds.Tables[0]; DataRow[] rows = tb.Select(sb.ToString()); if (tb.Rows.Count < 1) { return(null); } ListDataRow ret = DataSourceComm.readRow(tb, _schema, rows[0]); return(ret); }