[Adapdev-commits] Adapdev/src/Adapdev.Data/Schema ColumnSchema.cs,1.13,1.14 ForeignKeyAssociation.cs
Status: Beta
Brought to you by:
intesar66
From: Sean M. <int...@us...> - 2005-12-09 05:30:43
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Schema In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6721/src/Adapdev.Data/Schema Modified Files: ColumnSchema.cs ForeignKeyAssociation.cs LoadDatabaseSchema.cs Log Message: Fixed bug w/ NVelocity generated update statement Added support for many-to-many associations in ForeignKeyAssociation Index: ForeignKeyAssociation.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Schema/ForeignKeyAssociation.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ForeignKeyAssociation.cs 26 Nov 2005 08:09:22 -0000 1.9 --- ForeignKeyAssociation.cs 9 Dec 2005 05:30:31 -0000 1.10 *************** *** 1,4 **** --- 1,5 ---- using System; using System.ComponentModel; + using System.Xml.Serialization; namespace Adapdev.Data.Schema *************** *** 9,20 **** /// Summary description for ForeignKeyAssociation. /// </summary> public class ForeignKeyAssociation { private TableSchema _table = null; private ColumnSchema _foreignColumn = null; private TableSchema _foreignTable = null; ! private ColumnSchema _columnSchema = null; private AssociationType _association = AssociationType.OneToMany; [Browsable(false)] public ColumnSchema ForeignColumn --- 10,58 ---- /// Summary description for ForeignKeyAssociation. /// </summary> + /// public class ForeignKeyAssociation { private TableSchema _table = null; + private ColumnSchema _columnSchema = null; private ColumnSchema _foreignColumn = null; private TableSchema _foreignTable = null; ! private TableSchema _secondForeignTable = null; ! private ColumnSchema _secondForeignColumn = null; ! private TableSchema _thirdForeignTable = null; ! private ColumnSchema _thirdForeignColumn = null; private AssociationType _association = AssociationType.OneToMany; + public ForeignKeyAssociation(){} + + public ForeignKeyAssociation(TableSchema table, ColumnSchema columnSchema, TableSchema foreignTable, ColumnSchema foreignColumn) + { + this._table = table; + this._columnSchema = columnSchema; + this._foreignColumn = foreignColumn; + this._foreignTable = foreignTable; + } + + public ForeignKeyAssociation(TableSchema table, ColumnSchema columnSchema, TableSchema foreignTable, ColumnSchema foreignColumn, TableSchema secondForeignTable, ColumnSchema secondForeignColumn) + { + this._table = table; + this._columnSchema = columnSchema; + this._foreignColumn = foreignColumn; + this._foreignTable = foreignTable; + this._secondForeignColumn = secondForeignColumn; + this._secondForeignTable = secondForeignTable; + } + + public ForeignKeyAssociation(TableSchema table, ColumnSchema columnSchema, TableSchema foreignTable, ColumnSchema foreignColumn, TableSchema secondForeignTable, ColumnSchema secondForeignColumn, TableSchema thirdForeignTable, ColumnSchema thirdForeignColumn) + { + this._table = table; + this._columnSchema = columnSchema; + this._foreignColumn = foreignColumn; + this._foreignTable = foreignTable; + this._secondForeignColumn = secondForeignColumn; + this._secondForeignTable = secondForeignTable; + this._thirdForeignColumn = thirdForeignColumn; + this._thirdForeignTable = thirdForeignTable; + } + [Browsable(false)] public ColumnSchema ForeignColumn *************** *** 26,30 **** public string ForeignColumnName { ! get{return this._foreignColumn.Name;} } --- 64,88 ---- public string ForeignColumnName { ! get ! { ! if(this._foreignColumn != null) return this._foreignColumn.Name; ! else return String.Empty; ! } ! } ! ! [Browsable(false)] ! public ColumnSchema SecondForeignColumn ! { ! get { return _secondForeignColumn; } ! set { _secondForeignColumn = value; } ! } ! ! public string SecondForeignColumnName ! { ! get ! { ! if(this._secondForeignColumn != null) return this._secondForeignColumn.Name; ! else return String.Empty; ! } } *************** *** 38,42 **** public string ColumnName { ! get{return this._columnSchema.Name;} } --- 96,120 ---- public string ColumnName { ! get ! { ! if(this._columnSchema != null) return this._columnSchema.Name; ! else return String.Empty; ! } ! } ! ! [Browsable(false)] ! public TableSchema Table ! { ! get { return this._table; } ! set { _table = value; } ! } ! ! public string TableName ! { ! get ! { ! if(this._table != null) return this._table.Name; ! else return String.Empty; ! } } *************** *** 50,59 **** public string ForeignTableName { ! get{return this._foreignTable.Name;} } public string ForeignKeyName { ! get{return this._table.Name + "." + this.ColumnName + "-" + this.ForeignTableName + "." + this.ForeignColumnName;} } --- 128,197 ---- public string ForeignTableName { ! get ! { ! if(this._foreignTable != null) return this._foreignTable.Name; ! else return String.Empty; ! } ! } ! ! [Browsable(false)] ! public TableSchema SecondForeignTable ! { ! get { return _secondForeignTable; } ! set { _secondForeignTable = value; } ! } ! ! public string SecondForeignTableName ! { ! get ! { ! if(this._secondForeignTable != null) return this._secondForeignTable.Name; ! else return String.Empty; ! } ! } ! ! [Browsable(false)] ! public TableSchema ThirdForeignTable ! { ! get { return _thirdForeignTable; } ! set { _thirdForeignTable = value; } ! } ! ! public string ThirdForeignTableName ! { ! get ! { ! if(this._thirdForeignTable != null) return this._thirdForeignTable.Name; ! else return String.Empty; ! } ! } ! ! [Browsable(false)] ! public ColumnSchema ThirdForeignColumn ! { ! get { return _thirdForeignColumn; } ! set { _thirdForeignColumn = value; } ! } ! ! public string ThirdForeignColumnName ! { ! get ! { ! if(this._thirdForeignColumn != null) return this._thirdForeignColumn.Name; ! else return String.Empty; ! } } public string ForeignKeyName { ! get ! { ! if(this.SecondForeignTable != null && this.ThirdForeignTable != null) ! return this._table.Name + "." + this.ColumnName + "-" + this.ForeignTableName + "." + this.ForeignColumnName + "-" + this.SecondForeignTableName + "." + this.SecondForeignColumnName + "-" + this.ThirdForeignTableName + "." + this.ThirdForeignColumnName; ! else if(this.SecondForeignTable != null && this.ThirdForeignTable == null) ! return this._table.Name + "." + this.ColumnName + "-" + this.ForeignTableName + "." + this.ForeignColumnName + "-" + this.SecondForeignTableName + "." + this.SecondForeignColumnName; ! else ! return this._table.Name + "." + this.ColumnName + "-" + this.ForeignTableName + "." + this.ForeignColumnName; ! } } *************** *** 64,75 **** } - public ForeignKeyAssociation(TableSchema table, ColumnSchema columnSchema, TableSchema foreignTable, ColumnSchema foreignColumn) - { - this._table = table; - this._columnSchema = columnSchema; - this._foreignColumn = foreignColumn; - this._foreignTable = foreignTable; - } - [Browsable(false)] public override string ToString() --- 202,205 ---- Index: LoadDatabaseSchema.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Schema/LoadDatabaseSchema.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LoadDatabaseSchema.cs 16 Nov 2005 07:01:48 -0000 1.5 --- LoadDatabaseSchema.cs 9 Dec 2005 05:30:31 -0000 1.6 *************** *** 1,3 **** --- 1,4 ---- using System; + using Adapdev.Serialization; namespace Adapdev.Data.Schema *************** *** 25,37 **** public DatabaseSchema Load() { ! schemaFile = System.IO.Path.Combine(SchemaConstants.SCHEMAPATH,this._savedSchemaName); if(File.Exists(schemaFile)) { ! XmlSerializer dbSerializer = new XmlSerializer(typeof(DatabaseSchema)); ! FileStream dbStream = new FileStream(schemaFile, FileMode.Open); ! _dbSchema = (DatabaseSchema) dbSerializer.Deserialize(dbStream); ! dbStream.Close(); ! } return _dbSchema; } --- 26,44 ---- public DatabaseSchema Load() { ! schemaFile = Path.Combine(SchemaConstants.SCHEMAPATH,this._savedSchemaName); if(File.Exists(schemaFile)) { ! try ! { ! this._dbSchema = Serializer.DeserializeFromXmlFile(typeof(DatabaseSchema), schemaFile) as DatabaseSchema; ! } ! catch (Exception) ! { ! // Can't deserialize so let's get rid of it ! File.Delete(schemaFile); ! this._dbSchema = null; ! } ! } return _dbSchema; } Index: ColumnSchema.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Schema/ColumnSchema.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ColumnSchema.cs 26 Nov 2005 08:09:22 -0000 1.13 --- ColumnSchema.cs 9 Dec 2005 05:30:31 -0000 1.14 *************** *** 236,241 **** /// </summary> /// <value></value> - [XmlIgnore] [Browsable(false)] public ArrayList ForeignKeyTables { --- 236,242 ---- /// </summary> /// <value></value> [Browsable(false)] + // [XmlElement(Type = typeof(ForeignKeyAssociation))] + [XmlIgnore] public ArrayList ForeignKeyTables { *************** *** 268,271 **** --- 269,273 ---- } + [XmlIgnore] public string DbDataType { |