From: Kevin W. <kev...@us...> - 2004-12-31 22:25:54
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9327 Modified Files: SqlSelectBuilder.cs SqlSimpleSelectBuilder.cs SqlString.cs SqlStringBuilder.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: SqlSimpleSelectBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlSimpleSelectBuilder.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SqlSimpleSelectBuilder.cs 22 Nov 2004 03:56:08 -0000 1.2 --- SqlSimpleSelectBuilder.cs 31 Dec 2004 22:25:44 -0000 1.3 *************** *** 1,29 **** - using System; using System.Collections; - using System.Text; - - using NHibernate.Connection; - using NHibernate.Dialect; using NHibernate.Engine; - using NHibernate.Util; using NHibernate.Type; ! namespace NHibernate.SqlCommand { /// <summary> /// Summary description for SqlSimpleSelectBuilder. /// </summary> ! public class SqlSimpleSelectBuilder: SqlBaseBuilder, ISqlStringBuilder { ! ! ! string tableName; ! IList columnNames = new ArrayList(); // name of the column ! IList columnValues = new ArrayList(); //string or a Parameter ! IDictionary aliases = new Hashtable(); //key=column Name, value=column Alias ! int versionFragmentIndex = -1; ! int identityFragmentIndex = -1; ! IList whereStrings = new ArrayList(); //these can be plain strings because a forUpdate and orderBy will have --- 1,24 ---- using System.Collections; using NHibernate.Engine; using NHibernate.Type; + using NHibernate.Util; ! namespace NHibernate.SqlCommand ! { /// <summary> /// Summary description for SqlSimpleSelectBuilder. /// </summary> ! public class SqlSimpleSelectBuilder : SqlBaseBuilder, ISqlStringBuilder ! { ! private string tableName; ! private IList columnNames = new ArrayList(); // name of the column ! private IList columnValues = new ArrayList(); //string or a Parameter -- not used !?! ! private IDictionary aliases = new Hashtable(); //key=column Name, value=column Alias ! private int versionFragmentIndex = -1; // not used !?! ! private int identityFragmentIndex = -1; // not used !?! ! private IList whereStrings = new ArrayList(); //these can be plain strings because a forUpdate and orderBy will have *************** *** 33,41 **** private string orderBy; ! ! public SqlSimpleSelectBuilder(ISessionFactoryImplementor factory):base(factory) { } ! public SqlSimpleSelectBuilder SetTableName(string tableName) { this.tableName = tableName; return this; --- 28,46 ---- private string orderBy; ! /// <summary> ! /// ! /// </summary> ! /// <param name="factory"></param> ! public SqlSimpleSelectBuilder( ISessionFactoryImplementor factory ) : base( factory ) ! { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableName"></param> ! /// <returns></returns> ! public SqlSimpleSelectBuilder SetTableName( string tableName ) ! { this.tableName = tableName; return this; *************** *** 48,53 **** /// <param name="columnName">The name of the column to add.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumn(string columnName) { ! columnNames.Add(columnName); return this; } --- 53,59 ---- /// <param name="columnName">The name of the column to add.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumn( string columnName ) ! { ! columnNames.Add( columnName ); return this; } *************** *** 57,65 **** /// </summary> /// <param name="columnName">The name of the column to add.</param> ! /// <param name="aliase">The alias to use for the column</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumn(string columnName, string alias) { ! columnNames.Add(columnName); ! aliases[columnName] = alias; return this; } --- 63,72 ---- /// </summary> /// <param name="columnName">The name of the column to add.</param> ! /// <param name="alias">The alias to use for the column</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumn( string columnName, string alias ) ! { ! columnNames.Add( columnName ); ! aliases[ columnName ] = alias; return this; } *************** *** 70,76 **** /// <param name="columnNames">The names of the columns to add.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumns(string[] columnNames) { ! for (int i=0; i<columnNames.Length; i++) { ! AddColumn( columnNames[i]); } return this; --- 77,85 ---- /// <param name="columnNames">The names of the columns to add.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumns( string[ ] columnNames ) ! { ! for( int i = 0; i < columnNames.Length; i++ ) ! { ! AddColumn( columnNames[ i ] ); } return this; *************** *** 83,89 **** /// <param name="aliases">The aliases to use for the columns</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumns(string[] columnNames, string[] aliases) { ! for (int i=0; i<columnNames.Length; i++) { ! AddColumn( columnNames[i], aliases[i] ); } return this; --- 92,100 ---- /// <param name="aliases">The aliases to use for the columns</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumns( string[ ] columnNames, string[ ] aliases ) ! { ! for( int i = 0; i < columnNames.Length; i++ ) ! { ! AddColumn( columnNames[ i ], aliases[ i ] ); } return this; *************** *** 95,100 **** /// <param name="columnName">The name of the column to get the Alias for.</param> /// <returns>The Alias if one exists, null otherwise</returns> ! public string GetAlias(string columnName) { ! return (string) aliases[columnName]; } --- 106,112 ---- /// <param name="columnName">The name of the column to get the Alias for.</param> /// <returns>The Alias if one exists, null otherwise</returns> ! public string GetAlias( string columnName ) ! { ! return ( string ) aliases[ columnName ]; } *************** *** 105,113 **** /// <param name="identityType">The IType of the Identity Property.</param> /// <returns>The SqlSimpleSelectBuilder.</returns> ! public SqlSimpleSelectBuilder SetIdentityColumn(string[] columnNames, IType identityType) { ! Parameter[] parameters = Parameter.GenerateParameters( Factory, columnNames, identityType ); ! identityFragmentIndex = whereStrings.Add(ToWhereString(columnNames, parameters)); return this; --- 117,125 ---- /// <param name="identityType">The IType of the Identity Property.</param> /// <returns>The SqlSimpleSelectBuilder.</returns> ! public SqlSimpleSelectBuilder SetIdentityColumn( string[ ] columnNames, IType identityType ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( Factory, columnNames, identityType ); ! identityFragmentIndex = whereStrings.Add( ToWhereString( columnNames, parameters ) ); return this; *************** *** 120,128 **** /// <param name="versionType">The IVersionType of the Version Property.</param> /// <returns>The SqlSimpleSelectBuilder.</returns> ! public SqlSimpleSelectBuilder SetVersionColumn(string[] columnNames, IVersionType versionType) { ! Parameter[] parameters = Parameter.GenerateParameters( Factory, columnNames, versionType ); ! versionFragmentIndex = whereStrings.Add(ToWhereString(columnNames, parameters)); return this; --- 132,140 ---- /// <param name="versionType">The IVersionType of the Version Property.</param> /// <returns>The SqlSimpleSelectBuilder.</returns> ! public SqlSimpleSelectBuilder SetVersionColumn( string[ ] columnNames, IVersionType versionType ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( Factory, columnNames, versionType ); ! versionFragmentIndex = whereStrings.Add( ToWhereString( columnNames, parameters ) ); return this; *************** *** 134,138 **** /// <param name="fragment">The fragment to set.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder SetForUpdateFragment(string fragment){ this.forUpdateFragment = fragment; return this; --- 146,151 ---- /// <param name="fragment">The fragment to set.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder SetForUpdateFragment( string fragment ) ! { this.forUpdateFragment = fragment; return this; *************** *** 144,148 **** /// <param name="orderBy">The OrderBy fragment. It should include the SQL "ORDER BY"</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder SetOrderBy(string orderBy) { this.orderBy = orderBy; return this; --- 157,162 ---- /// <param name="orderBy">The OrderBy fragment. It should include the SQL "ORDER BY"</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder SetOrderBy( string orderBy ) ! { this.orderBy = orderBy; return this; *************** *** 156,172 **** /// <param name="op">The operator to put between the column name and value.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddWhereFragment(string[] columnNames, IType type, string op) { ! Parameter[] parameters = Parameter.GenerateParameters(Factory, columnNames, type); ! ! whereStrings.Add(ToWhereString(columnNames, parameters, op)); return this; } - #region ISqlStringBuilder Members ! public SqlString ToSqlString() { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); --- 170,187 ---- /// <param name="op">The operator to put between the column name and value.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddWhereFragment( string[ ] columnNames, IType type, string op ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( Factory, columnNames, type ); ! ! whereStrings.Add( ToWhereString( columnNames, parameters, op ) ); return this; } #region ISqlStringBuilder Members ! /// <summary></summary> ! public SqlString ToSqlString() ! { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); *************** *** 174,190 **** bool commaNeeded = false; - - sqlBuilder.Add("SELECT "); ! for(int i = 0; i < columnNames.Count; i++) { ! string column = (string)columnNames[i]; ! string alias = GetAlias(column); ! ! if(commaNeeded) sqlBuilder.Add(StringHelper.CommaSpace); ! ! sqlBuilder.Add(column); ! if(alias!=null && !alias.Equals(column)) { ! sqlBuilder.Add(" AS ") ! .Add(alias); } --- 189,210 ---- bool commaNeeded = false; ! sqlBuilder.Add( "SELECT " ); ! ! for( int i = 0; i < columnNames.Count; i++ ) ! { ! string column = ( string ) columnNames[ i ]; ! string alias = GetAlias( column ); ! ! if( commaNeeded ) ! { ! sqlBuilder.Add( StringHelper.CommaSpace ); ! } ! ! sqlBuilder.Add( column ); ! if( alias != null && !alias.Equals( column ) ) ! { ! sqlBuilder.Add( " AS " ) ! .Add( alias ); } *************** *** 193,218 **** ! sqlBuilder.Add(" FROM ") ! .Add(tableName); ! sqlBuilder.Add(" WHERE "); ! if(whereStrings.Count > 1) { sqlBuilder.Add( ! (SqlString[])((ArrayList)whereStrings).ToArray(typeof(SqlString)), ! null, "AND", null, false); } ! else { ! sqlBuilder.Add((SqlString)whereStrings[0], null, null, null, false); } ! if (forUpdateFragment!=null) { ! sqlBuilder.Add(" ") ! .Add(forUpdateFragment) ! .Add(" "); } ! if (orderBy!=null) ! sqlBuilder.Add(orderBy); return sqlBuilder.ToSqlString(); --- 213,243 ---- ! sqlBuilder.Add( " FROM " ) ! .Add( tableName ); ! sqlBuilder.Add( " WHERE " ); ! if( whereStrings.Count > 1 ) ! { sqlBuilder.Add( ! ( SqlString[ ] ) ( ( ArrayList ) whereStrings ).ToArray( typeof( SqlString ) ), ! null, "AND", null, false ); } ! else ! { ! sqlBuilder.Add( ( SqlString ) whereStrings[ 0 ], null, null, null, false ); } ! if( forUpdateFragment != null ) ! { ! sqlBuilder.Add( " " ) ! .Add( forUpdateFragment ) ! .Add( " " ); } ! if( orderBy != null ) ! { ! sqlBuilder.Add( orderBy ); ! } return sqlBuilder.ToSqlString(); *************** *** 221,223 **** #endregion } ! } --- 246,248 ---- #endregion } ! } \ No newline at end of file Index: SqlString.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlString.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** SqlString.cs 22 Nov 2004 03:56:08 -0000 1.16 --- SqlString.cs 31 Dec 2004 22:25:44 -0000 1.17 *************** *** 3,9 **** using System.Text; ! namespace NHibernate.SqlCommand { - /// <summary> /// This is a non-modifiable Sql statement that is ready to be prepared --- 3,8 ---- using System.Text; ! namespace NHibernate.SqlCommand { /// <summary> /// This is a non-modifiable Sql statement that is ready to be prepared *************** *** 14,34 **** /// </summary> [Serializable] ! public class SqlString : ICloneable { ! readonly object[] sqlParts; ! private int[] parameterIndexes; ! public SqlString(string sqlPart) : this(new object[] {sqlPart}) { } ! public SqlString(object[] sqlParts) { this.sqlParts = sqlParts; } ! public object[] SqlParts { ! get { return sqlParts;} } --- 13,42 ---- /// </summary> [Serializable] ! public class SqlString : ICloneable { ! private readonly object[ ] sqlParts; ! private int[ ] parameterIndexes; ! /// <summary> ! /// ! /// </summary> ! /// <param name="sqlPart"></param> ! public SqlString( string sqlPart ) : this( new object[ ] {sqlPart} ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sqlParts"></param> ! public SqlString( object[ ] sqlParts ) { this.sqlParts = sqlParts; } ! /// <summary></summary> ! public object[ ] SqlParts { ! get { return sqlParts; } } *************** *** 43,53 **** /// are called it is better to use the SqlStringBuilder. /// </remarks> ! public SqlString Append(SqlString rhs) { ! object[] temp = new object[rhs.SqlParts.Length + sqlParts.Length]; ! Array.Copy(sqlParts, 0, temp, 0, sqlParts.Length); ! Array.Copy(rhs.SqlParts, 0, temp, sqlParts.Length, rhs.SqlParts.Length); ! return new SqlString(temp); } --- 51,61 ---- /// are called it is better to use the SqlStringBuilder. /// </remarks> ! public SqlString Append( SqlString rhs ) { ! object[ ] temp = new object[rhs.SqlParts.Length + sqlParts.Length]; ! Array.Copy( sqlParts, 0, temp, 0, sqlParts.Length ); ! Array.Copy( rhs.SqlParts, 0, temp, sqlParts.Length, rhs.SqlParts.Length ); ! return new SqlString( temp ); } *************** *** 62,72 **** /// are called it is better to use the SqlStringBuilder. /// </remarks> ! public SqlString Append(string rhs) { ! object[] temp = new object[ sqlParts.Length + 1]; ! Array.Copy(sqlParts, 0, temp, 0, sqlParts.Length); ! temp[sqlParts.Length] = rhs; ! ! return new SqlString(temp); } --- 70,80 ---- /// are called it is better to use the SqlStringBuilder. /// </remarks> ! public SqlString Append( string rhs ) { ! object[ ] temp = new object[sqlParts.Length + 1]; ! Array.Copy( sqlParts, 0, temp, 0, sqlParts.Length ); ! temp[ sqlParts.Length ] = rhs; ! ! return new SqlString( temp ); } *************** *** 79,83 **** /// one SqlPart. /// </remarks> ! public SqlString Compact() { StringBuilder builder = new StringBuilder(); --- 87,91 ---- /// one SqlPart. /// </remarks> ! public SqlString Compact() { StringBuilder builder = new StringBuilder(); *************** *** 85,102 **** string builderString = String.Empty; ! foreach(object part in SqlParts) { string stringPart = part as string; ! if(stringPart!=null) { ! builder.Append(stringPart); } ! else { builderString = builder.ToString(); ! // don't add an empty string into the new compacted SqlString ! if( builderString.Length!=0 ) { sqlBuilder.Add( builderString ); --- 93,110 ---- string builderString = String.Empty; ! foreach( object part in SqlParts ) { string stringPart = part as string; ! if( stringPart != null ) { ! builder.Append( stringPart ); } ! else { builderString = builder.ToString(); ! // don't add an empty string into the new compacted SqlString ! if( builderString.Length != 0 ) { sqlBuilder.Add( builderString ); *************** *** 104,109 **** builder = new StringBuilder(); ! ! sqlBuilder.Add((Parameter)part); } --- 112,117 ---- builder = new StringBuilder(); ! ! sqlBuilder.Add( ( Parameter ) part ); } *************** *** 113,119 **** builderString = builder.ToString(); ! if(builderString.Length > 0) { ! sqlBuilder.Add(builderString); } --- 121,127 ---- builderString = builder.ToString(); ! if( builderString.Length > 0 ) { ! sqlBuilder.Add( builderString ); } *************** *** 125,138 **** /// </summary> /// <value>true if there is a Parameter with a null SqlType.</value> ! public bool ContainsUntypedParameter { ! get { ! for(int i=0; i<sqlParts.Length; i++) { ! Parameter paramPart = sqlParts[i] as Parameter; ! if(paramPart!=null) { ! if( paramPart.SqlType==null ) { // only need to find one null SqlType --- 133,146 ---- /// </summary> /// <value>true if there is a Parameter with a null SqlType.</value> ! public bool ContainsUntypedParameter { ! get { ! for( int i = 0; i < sqlParts.Length; i++ ) { ! Parameter paramPart = sqlParts[ i ] as Parameter; ! if( paramPart != null ) { ! if( paramPart.SqlType == null ) { // only need to find one null SqlType *************** *** 154,170 **** /// for the Count. /// </remarks> ! public int Count { ! get { int count = 0; ! for( int i=0; i<sqlParts.Length; i++ ) { ! SqlString sqlString = sqlParts[i] as SqlString; ! if( sqlString!=null ) { count += sqlString.Count; } ! else { count++; --- 162,178 ---- /// for the Count. /// </remarks> ! public int Count { ! get { int count = 0; ! for( int i = 0; i < sqlParts.Length; i++ ) { ! SqlString sqlString = sqlParts[ i ] as SqlString; ! if( sqlString != null ) { count += sqlString.Count; } ! else { count++; *************** *** 181,185 **** /// <param name="value">A string to seek at the end.</param> /// <returns><c>true</c> if the end of this instance matches value; otherwise, <c>false</c></returns> ! public bool EndsWith(string value) { SqlString tempSql = Compact(); --- 189,193 ---- /// <param name="value">A string to seek at the end.</param> /// <returns><c>true</c> if the end of this instance matches value; otherwise, <c>false</c></returns> ! public bool EndsWith( string value ) { SqlString tempSql = Compact(); *************** *** 187,191 **** int endIndex = tempSql.SqlParts.Length - 1; ! if( tempSql.SqlParts.Length==0 ) { return false; --- 195,199 ---- int endIndex = tempSql.SqlParts.Length - 1; ! if( tempSql.SqlParts.Length == 0 ) { return false; *************** *** 193,200 **** ! string lastPart = tempSql.SqlParts[endIndex] as string; ! if(lastPart!=null) { ! return lastPart.EndsWith(value); } --- 201,208 ---- ! string lastPart = tempSql.SqlParts[ endIndex ] as string; ! if( lastPart != null ) { ! return lastPart.EndsWith( value ); } *************** *** 208,231 **** /// An Int32 array that contains the indexes of the Parameters in the SqlPart array. /// </value> ! public int[] ParameterIndexes { get { // only calculate this one time because this object is immutable. ! if( parameterIndexes==null ) { ArrayList paramList = new ArrayList(); ! for(int i=0; i<sqlParts.Length; i++) { ! if(sqlParts[i] is Parameter) { ! paramList.Add(i); } } ! parameterIndexes = (int[])paramList.ToArray( typeof(int) ); } ! return parameterIndexes ; } --- 216,239 ---- /// An Int32 array that contains the indexes of the Parameters in the SqlPart array. /// </value> ! public int[ ] ParameterIndexes { get { // only calculate this one time because this object is immutable. ! if( parameterIndexes == null ) { ArrayList paramList = new ArrayList(); ! for( int i = 0; i < sqlParts.Length; i++ ) { ! if( sqlParts[ i ] is Parameter ) { ! paramList.Add( i ); } } ! parameterIndexes = ( int[ ] ) paramList.ToArray( typeof( int ) ); } ! return parameterIndexes; } *************** *** 242,246 **** /// in the Compacted form. /// </returns> ! public SqlString Replace(string oldValue, string newValue) { // compacting returns a new SqlString object, so we are free to modify --- 250,254 ---- /// in the Compacted form. /// </returns> ! public SqlString Replace( string oldValue, string newValue ) { // compacting returns a new SqlString object, so we are free to modify *************** *** 250,259 **** SqlString compacted = this.Compact(); ! for( int i=0; i<compacted.SqlParts.Length; i++ ) { ! string sqlPart = compacted.SqlParts[i] as string; ! if( sqlPart!=null ) { ! compacted.SqlParts[i] = sqlPart.Replace( oldValue, newValue ); } } --- 258,267 ---- SqlString compacted = this.Compact(); ! for( int i = 0; i < compacted.SqlParts.Length; i++ ) { ! string sqlPart = compacted.SqlParts[ i ] as string; ! if( sqlPart != null ) { ! compacted.SqlParts[ i ] = sqlPart.Replace( oldValue, newValue ); } } *************** *** 267,282 **** /// <param name="value">The System.String to seek</param> /// <returns>true if the SqlString starts with the value.</returns> ! public bool StartsWith(string value) { - SqlString tempSql = this.Compact(); ! foreach(object sqlPart in tempSql.SqlParts) { string partText = sqlPart as string; ! // if this part is not a string then we know we did not start with the string // value ! if(partText==null) { return false; --- 275,289 ---- /// <param name="value">The System.String to seek</param> /// <returns>true if the SqlString starts with the value.</returns> ! public bool StartsWith( string value ) { SqlString tempSql = this.Compact(); ! foreach( object sqlPart in tempSql.SqlParts ) { string partText = sqlPart as string; ! // if this part is not a string then we know we did not start with the string // value ! if( partText == null ) { return false; *************** *** 286,292 **** // move on to the next SqlPart, otherwise lets make sure that // it does in fact start with the value ! if(partText.Length > 0) { ! return partText.StartsWith(value); } } --- 293,299 ---- // move on to the next SqlPart, otherwise lets make sure that // it does in fact start with the value ! if( partText.Length > 0 ) { ! return partText.StartsWith( value ); } } *************** *** 312,332 **** /// will be the Parameter. /// </remarks> ! public SqlString Substring(int startIndex) { SqlStringBuilder builder = new SqlStringBuilder( Compact() ); ! string part = builder[0] as string; // if the first part is null then it is not a string so just // return them the compacted version ! if( part!=null ) { ! if(part.Length < startIndex) { ! builder.RemoveAt(0); } ! else { ! builder[0] = part.Substring(startIndex); } } --- 319,339 ---- /// will be the Parameter. /// </remarks> ! public SqlString Substring( int startIndex ) { SqlStringBuilder builder = new SqlStringBuilder( Compact() ); ! string part = builder[ 0 ] as string; // if the first part is null then it is not a string so just // return them the compacted version ! if( part != null ) { ! if( part.Length < startIndex ) { ! builder.RemoveAt( 0 ); } ! else { ! builder[ 0 ] = part.Substring( startIndex ); } } *************** *** 342,373 **** /// are removed from the beginning and end. /// </returns> ! public SqlString Trim() { SqlStringBuilder builder = new SqlStringBuilder( Compact() ); // there is nothing in the builder to Trim ! if( builder.Count==0 ) { return builder.ToSqlString(); } ! string begin = builder[0] as string; int endIndex = builder.Count - 1; ! string end = builder[endIndex] as string; ! if( endIndex==0 && begin!=null ) { ! builder[0] = begin.Trim(); } ! else { ! if(begin!=null) { ! builder[0] = begin.TrimStart(); } ! if(end!=null) { ! builder[builder.Count - 1] = end.TrimEnd(); } } --- 349,380 ---- /// are removed from the beginning and end. /// </returns> ! public SqlString Trim() { SqlStringBuilder builder = new SqlStringBuilder( Compact() ); // there is nothing in the builder to Trim ! if( builder.Count == 0 ) { return builder.ToSqlString(); } ! string begin = builder[ 0 ] as string; int endIndex = builder.Count - 1; ! string end = builder[ endIndex ] as string; ! if( endIndex == 0 && begin != null ) { ! builder[ 0 ] = begin.Trim(); } ! else { ! if( begin != null ) { ! builder[ 0 ] = begin.TrimStart(); } ! if( end != null ) { ! builder[ builder.Count - 1 ] = end.TrimEnd(); } } *************** *** 377,397 **** #region System.Object Members ! ! ! public override bool Equals(object obj) { SqlString rhs; ! // Step1: Perform an equals test ! if(obj==this) return true; // Step 2: Instance of check rhs = obj as SqlString; ! if(rhs==null) return false; //Step 3: Check each important field ! for(int i = 0; i < sqlParts.Length; i++) { ! if( this.sqlParts[i].Equals(rhs.SqlParts[i]) == false ) return false; } --- 384,417 ---- #region System.Object Members ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="obj"></param> ! /// <returns></returns> ! public override bool Equals( object obj ) { SqlString rhs; ! // Step1: Perform an equals test ! if( obj == this ) ! { ! return true; ! } // Step 2: Instance of check rhs = obj as SqlString; ! if( rhs == null ) ! { ! return false; ! } //Step 3: Check each important field ! for( int i = 0; i < sqlParts.Length; i++ ) { ! if( this.sqlParts[ i ].Equals( rhs.SqlParts[ i ] ) == false ) ! { ! return false; ! } } *************** *** 399,411 **** } public override int GetHashCode() { int hashCode = 0; ! unchecked { ! for(int i = 0; i < sqlParts.Length; i++) { ! hashCode += sqlParts[i].GetHashCode(); } } --- 419,432 ---- } + /// <summary></summary> public override int GetHashCode() { int hashCode = 0; ! unchecked { ! for( int i = 0; i < sqlParts.Length; i++ ) { ! hashCode += sqlParts[ i ].GetHashCode(); } } *************** *** 423,464 **** /// </summary> /// <returns>A Provider nuetral version of the CommandText</returns> ! public override string ToString() { ! StringBuilder builder = new StringBuilder(sqlParts.Length * 15); ! for(int i = 0; i < sqlParts.Length; i++) { ! builder.Append(sqlParts[i].ToString()); } return builder.ToString(); } ! #endregion ! #region ICloneable Members ! public SqlString Clone() { ! object[] clonedParts = new object[sqlParts.Length]; Parameter param; ! for(int i = 0; i < sqlParts.Length; i++) ! { ! param = sqlParts[i] as Parameter; ! if(param!=null) { ! clonedParts[i] = param.Clone(); } ! else { ! clonedParts[i] = (string)sqlParts[i]; } } ! return new SqlString(clonedParts); } ! object ICloneable.Clone() { return Clone(); --- 444,487 ---- /// </summary> /// <returns>A Provider nuetral version of the CommandText</returns> ! public override string ToString() { ! StringBuilder builder = new StringBuilder( sqlParts.Length*15 ); ! for( int i = 0; i < sqlParts.Length; i++ ) { ! builder.Append( sqlParts[ i ].ToString() ); } return builder.ToString(); } ! #endregion ! #region ICloneable Members ! /// <summary></summary> ! public SqlString Clone() { ! object[ ] clonedParts = new object[sqlParts.Length]; Parameter param; ! for( int i = 0; i < sqlParts.Length; i++ ) ! { ! param = sqlParts[ i ] as Parameter; ! if( param != null ) { ! clonedParts[ i ] = param.Clone(); } ! else { ! clonedParts[ i ] = ( string ) sqlParts[ i ]; } } ! return new SqlString( clonedParts ); } ! /// <summary></summary> ! object ICloneable.Clone() { return Clone(); *************** *** 467,469 **** #endregion } ! } --- 490,492 ---- #endregion } ! } \ No newline at end of file Index: SqlStringBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlStringBuilder.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SqlStringBuilder.cs 13 Sep 2004 07:22:38 -0000 1.5 --- SqlStringBuilder.cs 31 Dec 2004 22:25:44 -0000 1.6 *************** *** 2,6 **** using System.Collections; ! namespace NHibernate.SqlCommand { /// <summary> --- 2,6 ---- using System.Collections; ! namespace NHibernate.SqlCommand { /// <summary> *************** *** 27,40 **** /// to make sure the correct sql is getting built are specific to MsSql2000Dialect. /// </remarks> ! public class SqlStringBuilder : ISqlStringBuilder { - // this holds the strings and parameters that make up the full sql statement. ! ArrayList sqlParts; ! /// <summary> /// Create an empty StringBuilder with the default capacity. /// </summary> ! public SqlStringBuilder() : this(16) { } --- 27,39 ---- /// to make sure the correct sql is getting built are specific to MsSql2000Dialect. /// </remarks> ! public class SqlStringBuilder : ISqlStringBuilder { // this holds the strings and parameters that make up the full sql statement. ! private ArrayList sqlParts; ! /// <summary> /// Create an empty StringBuilder with the default capacity. /// </summary> ! public SqlStringBuilder() : this( 16 ) { } *************** *** 44,50 **** /// </summary> /// <param name="partsCapacity">The number of parts expected.</param> ! public SqlStringBuilder(int partsCapacity) { ! sqlParts = new ArrayList(partsCapacity); } --- 43,49 ---- /// </summary> /// <param name="partsCapacity">The number of parts expected.</param> ! public SqlStringBuilder( int partsCapacity ) { ! sqlParts = new ArrayList( partsCapacity ); } *************** *** 53,62 **** /// </summary> /// <param name="sqlString">The SqlString to modify.</param> ! public SqlStringBuilder(SqlString sqlString) { ! sqlParts = new ArrayList(sqlString.SqlParts.Length); ! foreach(object part in sqlString.SqlParts) { ! sqlParts.Add(part); } } --- 52,61 ---- /// </summary> /// <param name="sqlString">The SqlString to modify.</param> ! public SqlStringBuilder( SqlString sqlString ) { ! sqlParts = new ArrayList( sqlString.SqlParts.Length ); ! foreach( object part in sqlString.SqlParts ) { ! sqlParts.Add( part ); } } *************** *** 67,73 **** /// <param name="sql">The string to add.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add(string sql) { ! sqlParts.Add(sql); return this; } --- 66,72 ---- /// <param name="sql">The string to add.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add( string sql ) { ! sqlParts.Add( sql ); return this; } *************** *** 81,87 **** /// <param name="parameter">The Parameter to add.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add(Parameter parameter) { ! sqlParts.Add(parameter); return this; } --- 80,86 ---- /// <param name="parameter">The Parameter to add.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add( Parameter parameter ) { ! sqlParts.Add( parameter ); return this; } *************** *** 94,114 **** /// <returns>This SqlStringBuilder.</returns> /// <exception cref="ArgumentException">Thrown when the part is not a Parameter, String, or SqlString.</exception> ! public SqlStringBuilder AddObject(object part) { ! if(part is Parameter) { ! return this.Add((Parameter)part); } ! else if (part is String) { ! return this.Add((String)part); } ! else if (part is SqlString) { ! return this.Add((SqlString)part, null, null, null); } ! else { ! throw new ArgumentException("Part was not a Parameter, String, or SqlString."); } } --- 93,113 ---- /// <returns>This SqlStringBuilder.</returns> /// <exception cref="ArgumentException">Thrown when the part is not a Parameter, String, or SqlString.</exception> ! public SqlStringBuilder AddObject( object part ) { ! if( part is Parameter ) { ! return this.Add( ( Parameter ) part ); } ! else if( part is String ) { ! return this.Add( ( String ) part ); } ! else if( part is SqlString ) { ! return this.Add( ( SqlString ) part, null, null, null ); } ! else { ! throw new ArgumentException( "Part was not a Parameter, String, or SqlString." ); } } *************** *** 122,133 **** /// <returns>This SqlStringBuilder</returns> /// <remarks>This calls the overloaded Add(sqlString, null, null, null, false)</remarks> ! public SqlStringBuilder Add(SqlString sqlString) { ! return Add(sqlString, null, null, null, false); } - - /// <summary> /// Adds an existing SqlString to this SqlStringBuilder --- 121,130 ---- /// <returns>This SqlStringBuilder</returns> /// <remarks>This calls the overloaded Add(sqlString, null, null, null, false)</remarks> ! public SqlStringBuilder Add( SqlString sqlString ) { ! return Add( sqlString, null, null, null, false ); } /// <summary> /// Adds an existing SqlString to this SqlStringBuilder *************** *** 142,148 **** /// so it will not be wrapped with a "(" and ")" /// </remarks> ! public SqlStringBuilder Add(SqlString sqlString, string prefix, string op, string postfix) { ! return Add(new SqlString[] {sqlString}, prefix, op, postfix, false); } --- 139,145 ---- /// so it will not be wrapped with a "(" and ")" /// </remarks> ! public SqlStringBuilder Add( SqlString sqlString, string prefix, string op, string postfix ) { ! return Add( new SqlString[ ] {sqlString}, prefix, op, postfix, false ); } *************** *** 156,162 **** /// <param name="wrapStatement">Wrap each SqlStrings with "(" and ")"</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add(SqlString sqlString, string prefix, string op, string postfix, bool wrapStatement) { ! return Add(new SqlString[] {sqlString}, prefix, op, postfix, wrapStatement); } --- 153,159 ---- /// <param name="wrapStatement">Wrap each SqlStrings with "(" and ")"</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add( SqlString sqlString, string prefix, string op, string postfix, bool wrapStatement ) { ! return Add( new SqlString[ ] {sqlString}, prefix, op, postfix, wrapStatement ); } *************** *** 170,176 **** /// <returns>This SqlStringBuilder</returns> /// <remarks>This calls the overloaded Add method with wrapStatement=true</remarks> ! public SqlStringBuilder Add(SqlString[] sqlStrings, string prefix, string op, string postfix) { ! return Add(sqlStrings, prefix, op, postfix, true); } --- 167,173 ---- /// <returns>This SqlStringBuilder</returns> /// <remarks>This calls the overloaded Add method with wrapStatement=true</remarks> ! public SqlStringBuilder Add( SqlString[ ] sqlStrings, string prefix, string op, string postfix ) { ! return Add( sqlStrings, prefix, op, postfix, true ); } *************** *** 178,182 **** /// Adds existing SqlStrings to this SqlStringBuilder /// </summary> ! /// <param name="statements">The SqlStrings to combine.</param> /// <param name="prefix">String to put at the beginning of the combined SqlStrings.</param> /// <param name="op">How these SqlStrings should be junctioned "AND" or "OR"</param> --- 175,179 ---- /// Adds existing SqlStrings to this SqlStringBuilder /// </summary> ! /// <param name="sqlStrings">The SqlStrings to combine.</param> /// <param name="prefix">String to put at the beginning of the combined SqlStrings.</param> /// <param name="op">How these SqlStrings should be junctioned "AND" or "OR"</param> *************** *** 184,214 **** /// <param name="wrapStatement">Wrap each SqlStrings with "(" and ")"</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add(SqlString[] sqlStrings, string prefix, string op, string postfix, bool wrapStatement) { ! ! if( prefix!=null ) sqlParts.Add(prefix); ! bool opNeeded = false; ! ! foreach(SqlString sqlString in sqlStrings) { ! if(opNeeded) sqlParts.Add(" " + op + " "); ! ! opNeeded=true; ! if(wrapStatement) sqlParts.Add("("); ! ! foreach(object sqlPart in sqlString.SqlParts) { ! sqlParts.Add(sqlPart); } ! if(wrapStatement) sqlParts.Add(")"); ! ! } - if( postfix!=null ) sqlParts.Add(postfix); - return this; } --- 181,225 ---- /// <param name="wrapStatement">Wrap each SqlStrings with "(" and ")"</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add( SqlString[ ] sqlStrings, string prefix, string op, string postfix, bool wrapStatement ) { ! if( prefix != null ) ! { ! sqlParts.Add( prefix ); ! } ! bool opNeeded = false; ! ! foreach( SqlString sqlString in sqlStrings ) { ! if( opNeeded ) ! { ! sqlParts.Add( " " + op + " " ); ! } ! opNeeded = true; ! ! if( wrapStatement ) { ! sqlParts.Add( "(" ); } ! foreach( object sqlPart in sqlString.SqlParts ) ! { ! sqlParts.Add( sqlPart ); ! } ! ! if( wrapStatement ) ! { ! sqlParts.Add( ")" ); ! } ! ! ! } ! ! if( postfix != null ) ! { ! sqlParts.Add( postfix ); } return this; } *************** *** 230,243 **** /// <value>Returns a string or Parameter.</value> /// <remarks></remarks> ! public object this[int index] { ! get ! { ! return sqlParts[index]; ! } ! set ! { ! sqlParts[index] = value; ! } } --- 241,248 ---- /// <value>Returns a string or Parameter.</value> /// <remarks></remarks> ! public object this[ int index ] { ! get { return sqlParts[ index ]; } ! set { sqlParts[ index ] = value; } } *************** *** 248,254 **** /// <param name="sql">The string containing sql to insert.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Insert(int index, string sql) { ! sqlParts.Insert(index, sql); return this; } --- 253,259 ---- /// <param name="sql">The string containing sql to insert.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Insert( int index, string sql ) { ! sqlParts.Insert( index, sql ); return this; } *************** *** 260,266 **** /// <param name="param">The Parameter to insert.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Insert(int index, Parameter param) { ! sqlParts.Insert(index, param); return this; } --- 265,271 ---- /// <param name="param">The Parameter to insert.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Insert( int index, Parameter param ) { ! sqlParts.Insert( index, param ); return this; } *************** *** 271,277 **** /// <param name="index">The zero-based index of the item to remove.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder RemoveAt(int index) { ! sqlParts.RemoveAt(index); return this; } --- 276,282 ---- /// <param name="index">The zero-based index of the item to remove.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder RemoveAt( int index ) { ! sqlParts.RemoveAt( index ); return this; } *************** *** 281,288 **** /// </summary> /// <returns>The SqlString that was built.</returns> ! public SqlString ToSqlString() { ! return new SqlString((object[])sqlParts.ToArray(typeof(object))); } } ! } --- 286,293 ---- /// </summary> /// <returns>The SqlString that was built.</returns> ! public SqlString ToSqlString() { ! return new SqlString( ( object[ ] ) sqlParts.ToArray( typeof( object ) ) ); } } ! } \ No newline at end of file Index: SqlSelectBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlSelectBuilder.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SqlSelectBuilder.cs 4 Dec 2004 22:24:16 -0000 1.6 --- SqlSelectBuilder.cs 31 Dec 2004 22:25:44 -0000 1.7 *************** *** 1,20 **** using System; using System.Collections; ! using System.Data; ! using System.Text; ! ! using NHibernate.Connection; using NHibernate.Engine; using NHibernate.Type; - using NHibernate.Util; ! namespace NHibernate.SqlCommand { /// <summary> /// A class that builds an <c>INSERT</c> sql statement. /// </summary> ! public class SqlSelectBuilder: SqlBaseBuilder, ISqlStringBuilder { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(SqlSelectBuilder) ); private string selectClause; --- 1,16 ---- using System; using System.Collections; ! using log4net; using NHibernate.Engine; using NHibernate.Type; ! namespace NHibernate.SqlCommand { /// <summary> /// A class that builds an <c>INSERT</c> sql statement. /// </summary> ! public class SqlSelectBuilder : SqlBaseBuilder, ISqlStringBuilder { ! private static readonly ILog log = LogManager.GetLogger( typeof( SqlSelectBuilder ) ); private string selectClause; *************** *** 24,30 **** private string orderByClause; ! IList whereSqlStrings = new ArrayList(); ! public SqlSelectBuilder(ISessionFactoryImplementor factory): base(factory) { } --- 20,30 ---- private string orderByClause; ! private IList whereSqlStrings = new ArrayList(); ! /// <summary> ! /// ! /// </summary> ! /// <param name="factory"></param> ! public SqlSelectBuilder( ISessionFactoryImplementor factory ) : base( factory ) { } *************** *** 35,39 **** /// <param name="fromClause">The fromClause to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetFromClause(string fromClause) { this.fromClause = fromClause; --- 35,39 ---- /// <param name="fromClause">The fromClause to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetFromClause( string fromClause ) { this.fromClause = fromClause; *************** *** 47,51 **** /// <param name="alias">The Alias to use for the table name.</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetFromClause(string tableName, string alias) { this.fromClause = tableName + " " + alias; --- 47,51 ---- /// <param name="alias">The Alias to use for the table name.</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetFromClause( string tableName, string alias ) { this.fromClause = tableName + " " + alias; *************** *** 58,62 **** /// <param name="fromClause">The fromClause in a SqlString</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetFromClause(SqlString fromClause) { // it is safe to do this because a fromClause will have no --- 58,62 ---- /// <param name="fromClause">The fromClause in a SqlString</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetFromClause( SqlString fromClause ) { // it is safe to do this because a fromClause will have no *************** *** 70,74 **** /// <param name="orderByClause">The orderByClause to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetOrderByClause(string orderByClause) { this.orderByClause = orderByClause; --- 70,74 ---- /// <param name="orderByClause">The orderByClause to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetOrderByClause( string orderByClause ) { this.orderByClause = orderByClause; *************** *** 88,109 **** /// <param name="outerJoinsAfterWhere">The outerJoinsAfterWhere to set</param> /// <returns>The SqlSelectBuilder</returns> ! [Obsolete("Should use SqlString version instead")] ! public SqlSelectBuilder SetOuterJoins(string outerJoinsAfterFrom, string outerJoinsAfterWhere) { ! return this.SetOuterJoins( new SqlString(outerJoinsAfterFrom), new SqlString(outerJoinsAfterWhere) ); } ! [Obsolete("Should use SqlString version instead")] ! public SqlSelectBuilder SetOuterJoins(SqlString outerJoinsAfterFrom, string outerJoinsAfterWhere) { ! return this.SetOuterJoins( outerJoinsAfterFrom, new SqlString(outerJoinsAfterWhere) ); } ! [Obsolete("Should use SqlString version instead")] ! public SqlSelectBuilder SetOuterJoins(string outerJoinsAfterFrom, SqlString outerJoinsAfterWhere) { ! return this.SetOuterJoins( new SqlString(outerJoinsAfterFrom), outerJoinsAfterWhere ); } ! /// <summary> /// Sets the SqlString for the OUTER JOINs. --- 88,121 ---- /// <param name="outerJoinsAfterWhere">The outerJoinsAfterWhere to set</param> /// <returns>The SqlSelectBuilder</returns> ! [Obsolete( "Should use SqlString version instead" )] ! public SqlSelectBuilder SetOuterJoins( string outerJoinsAfterFrom, string outerJoinsAfterWhere ) { ! return this.SetOuterJoins( new SqlString( outerJoinsAfterFrom ), new SqlString( outerJoinsAfterWhere ) ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="outerJoinsAfterFrom"></param> ! /// <param name="outerJoinsAfterWhere"></param> ! /// <returns></returns> ! [Obsolete( "Should use SqlString version instead" )] ! public SqlSelectBuilder SetOuterJoins( SqlString outerJoinsAfterFrom, string outerJoinsAfterWhere ) { ! return this.SetOuterJoins( outerJoinsAfterFrom, new SqlString( outerJoinsAfterWhere ) ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="outerJoinsAfterFrom"></param> ! /// <param name="outerJoinsAfterWhere"></param> ! /// <returns></returns> ! [Obsolete( "Should use SqlString version instead" )] ! public SqlSelectBuilder SetOuterJoins( string outerJoinsAfterFrom, SqlString outerJoinsAfterWhere ) { ! return this.SetOuterJoins( new SqlString( outerJoinsAfterFrom ), outerJoinsAfterWhere ); } ! /// <summary> /// Sets the SqlString for the OUTER JOINs. *************** *** 116,120 **** /// <param name="outerJoinsAfterWhere">The outerJoinsAfterWhere to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetOuterJoins(SqlString outerJoinsAfterFrom, SqlString outerJoinsAfterWhere) { this.outerJoinsAfterFrom = outerJoinsAfterFrom; --- 128,132 ---- /// <param name="outerJoinsAfterWhere">The outerJoinsAfterWhere to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetOuterJoins( SqlString outerJoinsAfterFrom, SqlString outerJoinsAfterWhere ) { this.outerJoinsAfterFrom = outerJoinsAfterFrom; *************** *** 128,132 **** /// <param name="selectClause">The selectClause to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetSelectClause(string selectClause) { this.selectClause = selectClause; --- 140,144 ---- /// <param name="selectClause">The selectClause to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetSelectClause( string selectClause ) { this.selectClause = selectClause; *************** *** 141,149 **** /// <param name="whereType">The Hibernate Type</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetWhereClause(string tableAlias, string[] columnNames, IType whereType) { ! Parameter[] parameters = Parameter.GenerateParameters( Factory, tableAlias, columnNames, whereType ); ! whereSqlStrings.Add(ToWhereString(tableAlias, columnNames, parameters)); return this; --- 153,161 ---- /// <param name="whereType">The Hibernate Type</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetWhereClause( string tableAlias, string[ ] columnNames, IType whereType ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( Factory, tableAlias, columnNames, whereType ); ! whereSqlStrings.Add( ToWhereString( tableAlias, columnNames, parameters ) ); return this; *************** *** 156,168 **** /// <param name="whereSqlString">The SqlString that contains the sql and parameters to add to the WHERE</param> /// <returns>This SqlSelectBuilder</returns> ! public SqlSelectBuilder AddWhereClause(SqlString whereSqlString) { ! whereSqlStrings.Add(whereSqlString); return this; } - #region ISqlStringBuilder Members public SqlString ToSqlString() { --- 168,180 ---- /// <param name="whereSqlString">The SqlString that contains the sql and parameters to add to the WHERE</param> /// <returns>This SqlSelectBuilder</returns> ! public SqlSelectBuilder AddWhereClause( SqlString whereSqlString ) { ! whereSqlStrings.Add( whereSqlString ); return this; } #region ISqlStringBuilder Members + /// <summary></summary> public SqlString ToSqlString() { *************** *** 175,225 **** // move through each whereSqlString to find the capacity ! for( int i=0; i<whereSqlStrings.Count; i++ ) { ! initialCapacity += ((SqlString)whereSqlStrings[i]).Count; } ! SqlStringBuilder sqlBuilder = new SqlStringBuilder( initialCapacity + 2 ); ! sqlBuilder.Add("SELECT ") ! .Add(selectClause) ! .Add(" FROM ") ! .Add(fromClause) ! .Add(outerJoinsAfterFrom); ! sqlBuilder.Add(" WHERE "); ! if(whereSqlStrings.Count > 1) { sqlBuilder.Add( ! (SqlString[])((ArrayList)whereSqlStrings).ToArray(typeof(SqlString)), ! null, "AND", null, false); } ! else { ! sqlBuilder.Add( (SqlString)whereSqlStrings[0], null, null, null, false ); } ! sqlBuilder.Add(outerJoinsAfterWhere); ! ! if (orderByClause != null && orderByClause.Trim().Length > 0) { ! sqlBuilder.Add(" ORDER BY ") ! .Add(orderByClause); } ! if(log.IsDebugEnabled) { ! if( initialCapacity < sqlBuilder.Count ) { ! log.Debug( "The initial capacity was set too low at: " + initialCapacity + " for the SelectSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + fromClause ); } ! else if( initialCapacity > 16 && ((float)initialCapacity/sqlBuilder.Count) > 1.2 ) { log.Debug( "The initial capacity was set too high at: " + initialCapacity + " for the SelectSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + fromClause ); } } --- 187,237 ---- // move through each whereSqlString to find the capacity ! for( int i = 0; i < whereSqlStrings.Count; i++ ) { ! initialCapacity += ( ( SqlString ) whereSqlStrings[ i ] ).Count; } ! SqlStringBuilder sqlBuilder = new SqlStringBuilder( initialCapacity + 2 ); ! sqlBuilder.Add( "SELECT " ) ! .Add( selectClause ) ! .Add( " FROM " ) ! .Add( fromClause ) ! .Add( outerJoinsAfterFrom ); ! sqlBuilder.Add( " WHERE " ); ! if( whereSqlStrings.Count > 1 ) { sqlBuilder.Add( ! ( SqlString[ ] ) ( ( ArrayList ) whereSqlStrings ).ToArray( typeof( SqlString ) ), ! null, "AND", null, false ); } ! else { ! sqlBuilder.Add( ( SqlString ) whereSqlStrings[ 0 ], null, null, null, false ); } ! sqlBuilder.Add( outerJoinsAfterWhere ); ! ! if( orderByClause != null && orderByClause.Trim().Length > 0 ) { ! sqlBuilder.Add( " ORDER BY " ) ! .Add( orderByClause ); } ! if( log.IsDebugEnabled ) { ! if( initialCapacity < sqlBuilder.Count ) { ! log.Debug( "The initial capacity was set too low at: " + initialCapacity + " for the SelectSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + fromClause ); } ! else if( initialCapacity > 16 && ( ( float ) initialCapacity/sqlBuilder.Count ) > 1.2 ) { log.Debug( "The initial capacity was set too high at: " + initialCapacity + " for the SelectSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + fromClause ); } } *************** *** 228,233 **** } - #endregion } ! } --- 240,245 ---- } + #endregion } ! } \ No newline at end of file |