[Adapdev-commits] Adapdev/src/Adapdev.Data/Schema ColumnSchema.cs,1.2,1.3 DatabaseSchema.cs,1.1.1.1,
Status: Beta
Brought to you by:
intesar66
From: Sean M. <int...@us...> - 2005-03-25 02:14:38
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Schema In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9855/src/Adapdev.Data/Schema Modified Files: ColumnSchema.cs DatabaseSchema.cs SchemaBuilder.cs TableSchema.cs TableSchemaCollection.cs Log Message: Index: DatabaseSchema.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Schema/DatabaseSchema.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** DatabaseSchema.cs 28 Feb 2005 01:31:47 -0000 1.1.1.1 --- DatabaseSchema.cs 25 Mar 2005 02:14:29 -0000 1.2 *************** *** 102,108 **** /// </summary> /// <returns></returns> ! public TableSchemaDictionary GetTables() { ! return this.tables; } --- 102,109 ---- /// </summary> /// <returns></returns> ! public TableSchemaDictionary Tables { ! get{return this.tables;} ! set{this.tables = value;} } *************** *** 111,127 **** /// </summary> /// <returns>SortedList</returns> ! public SortedList GetSortedTables() { ! SortedList sl = new SortedList(); ! foreach (TableSchema t in this.tables.Values) { ! sl.Add(t.Name, t); } - return sl; } public override string ToString() { ! return Environment.NewLine + StringUtil.ToString(this) + Environment.NewLine + this.GetTables().ToString(); } --- 112,131 ---- /// </summary> /// <returns>SortedList</returns> ! public SortedList SortedTables { ! get { ! SortedList sl = new SortedList(); ! foreach (TableSchema t in this.tables.Values) ! { ! sl.Add(t.Name, t); ! } ! return sl; } } public override string ToString() { ! return Environment.NewLine + StringUtil.ToString(this) + Environment.NewLine + this.Tables.ToString(); } Index: TableSchemaCollection.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Schema/TableSchemaCollection.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** TableSchemaCollection.cs 28 Feb 2005 01:31:47 -0000 1.1.1.1 --- TableSchemaCollection.cs 25 Mar 2005 02:14:29 -0000 1.2 *************** *** 6,9 **** --- 6,12 ---- namespace Adapdev.Data.Schema { + using System.Text; + using Adapdev.Text; + [Serializable()] public class TableSchemaCollection : CollectionBase Index: TableSchema.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Schema/TableSchema.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TableSchema.cs 17 Mar 2005 12:50:11 -0000 1.2 --- TableSchema.cs 25 Mar 2005 02:14:29 -0000 1.3 *************** *** 16,19 **** --- 16,20 ---- protected string _alias = String.Empty; protected ColumnSchemaDictionary columns = new ColumnSchemaDictionary(); + protected DatabaseSchema parent = null; /// <summary> *************** *** 58,64 **** /// </summary> /// <returns></returns> ! public ColumnSchemaDictionary GetColumns() { ! return this.columns; } --- 59,66 ---- /// </summary> /// <returns></returns> ! public ColumnSchemaDictionary Columns { ! get{return this.columns;} ! set{this.columns = value;} } *************** *** 67,78 **** /// </summary> /// <returns></returns> ! public ColumnSchemaDictionary GetPrimaryKeys() { ! ColumnSchemaDictionary pks = new ColumnSchemaDictionary(); ! foreach(ColumnSchema c in this.columns.Values) { ! if(c.IsPrimaryKey)pks[c.Name] = c; } - return pks; } --- 69,83 ---- /// </summary> /// <returns></returns> ! public ColumnSchemaDictionary PrimaryKeys { ! get { ! ColumnSchemaDictionary pks = new ColumnSchemaDictionary(); ! foreach(ColumnSchema c in this.columns.Values) ! { ! if(c.IsPrimaryKey)pks[c.Name] = c; ! } ! return pks; } } *************** *** 81,92 **** /// </summary> /// <returns></returns> ! public ColumnSchemaDictionary GetForeignKeys() { ! ColumnSchemaDictionary fks = new ColumnSchemaDictionary(); ! foreach(ColumnSchema c in this.columns.Values) { ! if(c.IsForeignKey)fks[c.Name] = c; } - return fks; } --- 86,100 ---- /// </summary> /// <returns></returns> ! public ColumnSchemaDictionary ForeignKeys { ! get { ! ColumnSchemaDictionary fks = new ColumnSchemaDictionary(); ! foreach(ColumnSchema c in this.columns.Values) ! { ! if(c.IsForeignKey)fks[c.Name] = c; ! } ! return fks; } } *************** *** 95,106 **** /// </summary> /// <returns></returns> ! public int GetPrimaryKeyCount() { ! int i = 0; ! foreach (ColumnSchema c in columns.Values) { ! if(c.IsPrimaryKey)i++; ! } ! return i; } --- 103,117 ---- /// </summary> /// <returns></returns> ! public int PrimaryKeyCount { ! get { ! int i = 0; ! foreach (ColumnSchema c in columns.Values) ! { ! if(c.IsPrimaryKey)i++; ! } ! return i; ! } } *************** *** 109,120 **** /// </summary> /// <returns></returns> ! public int GetForeignKeyCount() { ! int i = 0; ! foreach (ColumnSchema c in columns.Values) { ! if(c.IsForeignKey)i++; } - return i; } --- 120,134 ---- /// </summary> /// <returns></returns> ! public int ForeignKeyCount { ! get { ! int i = 0; ! foreach (ColumnSchema c in columns.Values) ! { ! if(c.IsForeignKey)i++; ! } ! return i; } } *************** *** 131,135 **** public ColumnSchema GetPrimaryKey(int index) { ! ArrayList al = new ArrayList(this.GetPrimaryKeys().Values); return ((ColumnSchema) al[index]); } --- 145,149 ---- public ColumnSchema GetPrimaryKey(int index) { ! ArrayList al = new ArrayList(this.PrimaryKeys.Values); return ((ColumnSchema) al[index]); } *************** *** 147,151 **** public ColumnSchema GetForeignKey(int index) { ! ArrayList al = new ArrayList(this.GetForeignKeys().Values); return ((ColumnSchema) al[index]); } --- 161,165 ---- public ColumnSchema GetForeignKey(int index) { ! ArrayList al = new ArrayList(this.ForeignKeys.Values); return ((ColumnSchema) al[index]); } *************** *** 155,166 **** /// </summary> /// <returns></returns> ! public SortedList GetOrdinalColumns() { ! SortedList sl = new SortedList(); ! foreach (ColumnSchema c in this.columns.Values) { ! sl[c.Ordinal] = c; } - return sl; } --- 169,183 ---- /// </summary> /// <returns></returns> ! public SortedList OrdinalColumns { ! get { ! SortedList sl = new SortedList(); ! foreach (ColumnSchema c in this.columns.Values) ! { ! sl[c.Ordinal] = c; ! } ! return sl; } } *************** *** 169,180 **** /// </summary> /// <returns></returns> ! public SortedList GetSortedColumns() { ! SortedList sl = new SortedList(); ! foreach (ColumnSchema c in this.columns.Values) { ! sl.Add(c.Name, c); } - return sl; } --- 186,200 ---- /// </summary> /// <returns></returns> ! public SortedList SortedColumns { ! get { ! SortedList sl = new SortedList(); ! foreach (ColumnSchema c in this.columns.Values) ! { ! sl.Add(c.Name, c); ! } ! return sl; } } *************** *** 225,229 **** get { ! if(this.GetForeignKeyCount() > 0) return true; else return false; } --- 245,249 ---- get { ! if(this.ForeignKeyCount > 0) return true; else return false; } *************** *** 234,238 **** get { ! if(this.GetPrimaryKeyCount() > 0) return true; else return false; } --- 254,258 ---- get { ! if(this.PrimaryKeyCount > 0) return true; else return false; } *************** *** 241,245 **** public override string ToString() { ! return Environment.NewLine + StringUtil.ToString(this) + Environment.NewLine + this.GetColumns().ToString(); } --- 261,265 ---- public override string ToString() { ! return Environment.NewLine + StringUtil.ToString(this) + Environment.NewLine + this.Columns.ToString(); } Index: SchemaBuilder.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Schema/SchemaBuilder.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** SchemaBuilder.cs 28 Feb 2005 01:31:47 -0000 1.1.1.1 --- SchemaBuilder.cs 25 Mar 2005 02:14:29 -0000 1.2 *************** *** 54,57 **** --- 54,58 ---- } + // Build the base schema information foreach (DataRow dr in schemaTables.Rows) { *************** *** 65,68 **** --- 66,70 ---- } + // Get the primary key information DataTable pkeys = SchemaBuilder.GetOleDbSchema(oledbConnectionString, OleDbSchemaGuid.Primary_Keys, ""); foreach (DataRow dr in pkeys.Rows) *************** *** 82,85 **** --- 84,88 ---- } + // Get the foreign key information DataTable fkeys = SchemaBuilder.GetOleDbSchema(oledbConnectionString, OleDbSchemaGuid.Foreign_Keys, ""); foreach (DataRow dr in fkeys.Rows) *************** *** 94,99 **** ci.IsForeignKey = true; tif.AddColumn(ci); ! ci.ForeignKeyTables.Add(di.GetTable(fkTable)); } } --- 97,128 ---- ci.IsForeignKey = true; tif.AddColumn(ci); + } + } + } ! // Get the foreign key associations ! foreach (DataRow dr in fkeys.Rows) ! { ! // Get the name of the primary key table ! string pkTable = dr["PK_TABLE_NAME"].ToString(); ! // Get the name of the foreign key table ! string fkTable = dr["FK_TABLE_NAME"].ToString(); ! // Get the name of the foreign key column ! string fkColumn = dr["FK_COLUMN_NAME"].ToString(); ! ! // Get the table containing the primary key ! TableSchema tif = di[pkTable]; ! // Get the table containing the foreign key ! TableSchema fk = di[fkTable]; ! if (tif != null) ! { ! // Get the primary key ! ColumnSchema ci = tif[dr["PK_COLUMN_NAME"].ToString()]; ! // Get the foreign key ! ColumnSchema cf = fk[fkColumn]; ! if (ci != null) ! { ! // Add the association to the table and column containing the foreign key ! ci.ForeignKeyTables.Add(new ForeignKeyAssociation(ci, cf ,fk)); } } Index: ColumnSchema.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Schema/ColumnSchema.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ColumnSchema.cs 17 Mar 2005 12:50:11 -0000 1.2 --- ColumnSchema.cs 25 Mar 2005 02:14:29 -0000 1.3 *************** *** 28,32 **** private string _defaultValue = String.Empty; private string _defaultTestValue = String.Empty; ! private TableSchemaCollection _fkReferences = new TableSchemaCollection(); /// <summary> --- 28,33 ---- private string _defaultValue = String.Empty; private string _defaultTestValue = String.Empty; ! private ArrayList _fkReferences = new ArrayList(); ! private TableSchema _parent = null; /// <summary> *************** *** 198,202 **** /// </summary> /// <value></value> ! public TableSchemaCollection ForeignKeyTables { get{ return this._fkReferences;} --- 199,203 ---- /// </summary> /// <value></value> ! public ArrayList ForeignKeyTables { get{ return this._fkReferences;} |