[Adapdev-commits] Adapdev/src/Adapdev.Data/Sql Criteria.cs,1.6,1.7 DeleteQuery.cs,1.5,1.6 ICriteria.
Status: Beta
Brought to you by:
intesar66
From: Sean M. <int...@us...> - 2005-12-30 20:42:24
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Sql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4251/src/Adapdev.Data/Sql Modified Files: Criteria.cs DeleteQuery.cs ICriteria.cs IQuery.cs InsertQuery.cs SelectQuery.cs UpdateQuery.cs Log Message: Several bug fixes to the Adapdev.Data.Sql namespace Index: InsertQuery.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Sql/InsertQuery.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** InsertQuery.cs 16 Nov 2005 07:01:48 -0000 1.5 --- InsertQuery.cs 30 Dec 2005 20:42:11 -0000 1.6 *************** *** 19,23 **** protected DbProviderType provider = DbProviderType.SQLSERVER; ! public InsertQuery(DbType type, DbProviderType provider) { this.type = type; --- 19,23 ---- protected DbProviderType provider = DbProviderType.SQLSERVER; ! internal InsertQuery(DbType type, DbProviderType provider) { this.type = type; *************** *** 25,29 **** } ! public InsertQuery(DbType type, DbProviderType provider, string tableName) : this(type, provider) { this.SetTable(tableName); --- 25,29 ---- } ! internal InsertQuery(DbType type, DbProviderType provider, string tableName) : this(type, provider) { this.SetTable(tableName); *************** *** 101,104 **** --- 101,110 ---- set { this.provider = value; } } + + public ICriteria Criteria + { + get { return this.criteria; } + } + } } \ No newline at end of file Index: SelectQuery.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Sql/SelectQuery.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SelectQuery.cs 26 Nov 2005 09:08:59 -0000 1.10 --- SelectQuery.cs 30 Dec 2005 20:42:11 -0000 1.11 *************** *** 19,23 **** protected string _join = ""; ! public SelectQuery(DbType type, DbProviderType provider) { this.type = type; --- 19,23 ---- protected string _join = ""; ! internal SelectQuery(DbType type, DbProviderType provider) { this.type = type; *************** *** 25,29 **** } ! public SelectQuery(DbType type, DbProviderType provider, string tableName): this(type, provider) { this.SetTable(tableName); --- 25,29 ---- } ! internal SelectQuery(DbType type, DbProviderType provider, string tableName): this(type, provider) { this.SetTable(tableName); *************** *** 186,189 **** --- 186,194 ---- } + public ICriteria Criteria + { + get { return criteria; } + } + public OrderBy OrderBy { Index: UpdateQuery.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Sql/UpdateQuery.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** UpdateQuery.cs 16 Nov 2005 07:01:48 -0000 1.5 --- UpdateQuery.cs 30 Dec 2005 20:42:11 -0000 1.6 *************** *** 15,19 **** protected DbProviderType provider = DbProviderType.SQLSERVER; ! public UpdateQuery(DbType type, DbProviderType provider) { this.type = type; --- 15,19 ---- protected DbProviderType provider = DbProviderType.SQLSERVER; ! internal UpdateQuery(DbType type, DbProviderType provider) { this.type = type; *************** *** 21,25 **** } ! public UpdateQuery(DbType type, DbProviderType provider, string tableName) : this(type, provider) { this.SetTable(tableName); --- 21,25 ---- } ! internal UpdateQuery(DbType type, DbProviderType provider, string tableName) : this(type, provider) { this.SetTable(tableName); *************** *** 72,75 **** --- 72,81 ---- set { this.provider = value; } } + + public ICriteria Criteria + { + get { return this.criteria; } + } + } } \ No newline at end of file Index: Criteria.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Sql/Criteria.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Criteria.cs 16 Nov 2005 07:01:48 -0000 1.6 --- Criteria.cs 30 Dec 2005 20:42:11 -0000 1.7 *************** *** 1,2 **** --- 1,4 ---- + using System; + namespace Adapdev.Data.Sql { *************** *** 13,16 **** --- 15,19 ---- protected DbType type = DbType.SQLSERVER; protected DbProviderType provider = DbProviderType.SQLSERVER; + protected bool initialized = false; public Criteria(DbType type, DbProviderType provider) *************** *** 28,40 **** public void AddAnd() { ! this.AddCriteriaSeparator(CriteriaType.AND); } public virtual void AddAndCriteria(ICriteria c) { ! this.AddAnd(); ! sb.Append("("); ! sb.Append(c.GetText()); ! sb.Append(") "); } --- 31,47 ---- public void AddAnd() { ! if(this.initialized)this.AddCriteriaSeparator(CriteriaType.AND); } public virtual void AddAndCriteria(ICriteria c) { ! if(c.Initialized) ! { ! this.AddAnd(); ! sb.Append("("); ! sb.Append(c.GetText().Replace("WHERE","")); ! sb.Append(") "); ! this.initialized = true; ! } } *************** *** 56,59 **** --- 63,67 ---- sb.Append(QueryHelper.DressUp(value2,this.type)); sb.Append(" "); + this.initialized = true; } *************** *** 67,70 **** --- 75,79 ---- sb.Append(QueryHelper.DressUp(columnValue,this.type)); sb.Append(" "); + this.initialized = true; } *************** *** 82,85 **** --- 91,95 ---- sb.Append(QueryHelper.DressUp(columnValue,this.type)); sb.Append(" "); + this.initialized = true; } *************** *** 93,96 **** --- 103,107 ---- sb.Append(QueryHelper.GetParameterName(columnName, this.DbProviderType)); sb.Append(" "); + this.initialized = true; } *************** *** 108,111 **** --- 119,123 ---- sb.Append(QueryHelper.DressUp(columnValue,this.type)); sb.Append(" "); + this.initialized = true; } *************** *** 119,122 **** --- 131,135 ---- sb.Append(QueryHelper.DressUp(columnValue,this.type)); sb.Append(" "); + this.initialized = true; } *************** *** 126,129 **** --- 139,143 ---- sb.Append(subQuery.GetText()); sb.Append(") "); + this.initialized = true; } *************** *** 140,143 **** --- 154,158 ---- sb.Append(StringUtil.RemoveFinalComma(sbo.ToString())); sb.Append(") "); + this.initialized = true; } *************** *** 149,152 **** --- 164,168 ---- sb.Append(QueryHelper.GetPostDelimeter(this.type)); sb.Append(" IS NULL "); + this.initialized = true; } *************** *** 160,163 **** --- 176,180 ---- sb.Append(QueryHelper.DressUp(columnValue,this.type)); sb.Append(" "); + this.initialized = true; } *************** *** 171,174 **** --- 188,192 ---- sb.Append(QueryHelper.DressUp(columnValue,this.type)); sb.Append(" "); + this.initialized = true; } *************** *** 182,185 **** --- 200,204 ---- sb.Append(QueryHelper.DressUp(columnValue,this.type)); sb.Append(" "); + this.initialized = true; } *************** *** 195,198 **** --- 214,218 ---- sb.Append(QueryHelper.DressUp(value2, this.type)); sb.Append(" "); + this.initialized = true; } *************** *** 206,209 **** --- 226,230 ---- sb.Append(QueryHelper.DressUp(columnValue,this.type)); sb.Append(" "); + this.initialized = true; } *************** *** 211,214 **** --- 232,236 ---- { sb.Append(" EXISTS (" + subQuery.GetText() + ") "); + this.initialized = true; } *************** *** 224,227 **** --- 246,250 ---- sb.Append(StringUtil.RemoveFinalComma(sbo.ToString())); sb.Append(")"); + this.initialized = true; } *************** *** 229,232 **** --- 252,256 ---- { sb.Append(" NOT IN (" + subQuery.GetText() + ") "); + this.initialized = true; } *************** *** 240,243 **** --- 264,268 ---- sb.Append(QueryHelper.DressUp(columnValue,this.type)); sb.Append(" "); + this.initialized = true; } *************** *** 249,263 **** sb.Append(QueryHelper.GetPostDelimeter(this.type)); sb.Append(" NOT IS NULL "); } public void AddOr() { ! this.AddCriteriaSeparator(CriteriaType.OR); } public void AddOrCriteria(ICriteria c) { ! this.AddOr(); ! sb.Append("(" + c.GetText() + ")"); } --- 274,293 ---- sb.Append(QueryHelper.GetPostDelimeter(this.type)); sb.Append(" NOT IS NULL "); + this.initialized = true; } public void AddOr() { ! if(this.initialized)this.AddCriteriaSeparator(CriteriaType.OR); } public void AddOrCriteria(ICriteria c) { ! if(c.Initialized) ! { ! this.AddOr(); ! sb.Append("(" + c.GetText().Replace("WHERE","") + ")"); ! this.initialized = true; ! } } *************** *** 265,273 **** { sb.Append(sql); } public virtual string GetText() { ! if (sb.Length > 2) { return " WHERE " + sb.ToString(); --- 295,304 ---- { sb.Append(sql); + this.initialized = true; } public virtual string GetText() { ! if (this.initialized) { return " WHERE " + sb.ToString(); *************** *** 279,282 **** --- 310,318 ---- } + public bool Initialized + { + get { return this.initialized; } + } + public DbProviderType DbProviderType { Index: DeleteQuery.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Sql/DeleteQuery.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DeleteQuery.cs 16 Nov 2005 07:01:48 -0000 1.5 --- DeleteQuery.cs 30 Dec 2005 20:42:11 -0000 1.6 *************** *** 11,15 **** protected DbProviderType provider = DbProviderType.SQLSERVER; ! public DeleteQuery(DbType type, DbProviderType provider) { this.type = type; --- 11,15 ---- protected DbProviderType provider = DbProviderType.SQLSERVER; ! internal DeleteQuery(DbType type, DbProviderType provider) { this.type = type; *************** *** 17,21 **** } ! public DeleteQuery(DbType type, DbProviderType provider, string tableName) : this(type, provider) { this.SetTable(tableName); --- 17,21 ---- } ! internal DeleteQuery(DbType type, DbProviderType provider, string tableName) : this(type, provider) { this.SetTable(tableName); *************** *** 53,56 **** --- 53,62 ---- set { this.provider = value; } } + + public ICriteria Criteria + { + get { return this.criteria; } + } + } } \ No newline at end of file Index: ICriteria.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Sql/ICriteria.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ICriteria.cs 16 Nov 2005 07:01:48 -0000 1.6 --- ICriteria.cs 30 Dec 2005 20:42:11 -0000 1.7 *************** *** 35,38 **** --- 35,39 ---- void AddSql(string sql); string GetText(); + bool Initialized{get;} DbProviderType DbProviderType { get; set; } } Index: IQuery.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Sql/IQuery.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IQuery.cs 16 Nov 2005 07:01:48 -0000 1.5 --- IQuery.cs 30 Dec 2005 20:42:11 -0000 1.6 *************** *** 33,36 **** --- 33,37 ---- /// </summary> DbProviderType DbProviderType { get; set; } + ICriteria Criteria{get;} } } \ No newline at end of file |