Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23509/NHibernate/SqlCommand
Modified Files:
SqlString.cs
Log Message:
Added methods to SqlString and tests for them.
Index: SqlString.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlString.cs,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** SqlString.cs 18 Aug 2004 20:15:04 -0000 1.11
--- SqlString.cs 20 Aug 2004 15:26:24 -0000 1.12
***************
*** 1,3 ****
--- 1,4 ----
using System;
+ using System.Collections;
using System.Text;
***************
*** 16,20 ****
{
readonly object[] sqlParts;
!
public SqlString(string sqlPart) : this(new object[] {sqlPart})
{
--- 17,22 ----
{
readonly object[] sqlParts;
! private int[] parameterIndexes;
!
public SqlString(string sqlPart) : this(new object[] {sqlPart})
{
***************
*** 120,123 ****
--- 122,150 ----
/// <summary>
+ /// Gets a bool that indicates if there is a Parameter that has a null SqlType.
+ /// </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
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+ }
+
+ /// <summary>
/// Determines whether the end of this instance matches the specified String.
/// </summary>
***************
*** 146,149 ****
--- 173,205 ----
/// <summary>
+ /// Gets the indexes of the Parameters in the SqlParts
+ /// </summary>
+ /// <value>
+ /// 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 ;
+ }
+
+ }
+ /// <summary>
/// Determines whether the beginning of this SqlString matches the specified System.String
/// </summary>
|