public void DeleteSqlStringTest()
		{
			Configuration cfg = new Configuration();
			ISessionFactory factory = cfg.BuildSessionFactory();

			ISessionFactoryImplementor factoryImpl = (ISessionFactoryImplementor) factory;
			SqlDeleteBuilder delete = new SqlDeleteBuilder(factoryImpl.Dialect, factoryImpl);

			delete.SetTableName("test_delete_builder");


			delete.SetIdentityColumn(new string[] {"decimalColumn"}, NHibernateUtil.Decimal);
			delete.SetVersionColumn(new string[] {"versionColumn"}, (IVersionType) NHibernateUtil.Int32);

			delete.AddWhereFragment("a=b");

			SqlCommandInfo sqlCommand = delete.ToSqlCommandInfo();

			string expectedSql = "DELETE FROM test_delete_builder WHERE decimalColumn = ? AND versionColumn = ? AND a=b";
			Assert.AreEqual(expectedSql, sqlCommand.Text.ToString(), "SQL String");

			SqlType[] actualParameterTypes = sqlCommand.ParameterTypes;
			Assert.AreEqual(2, actualParameterTypes.Length, "Two parameters");

			Assert.AreEqual(SqlTypeFactory.Decimal, actualParameterTypes[0], "firstParam Type");
			Assert.AreEqual(SqlTypeFactory.Int32, actualParameterTypes[1], "secondParam Type");
		}
		public void DeleteSqlStringTest() {
			Configuration cfg = new Configuration();
			ISessionFactory factory = cfg.BuildSessionFactory( );

			ISessionFactoryImplementor factoryImpl = (ISessionFactoryImplementor)factory;
			SqlDeleteBuilder delete = new SqlDeleteBuilder(factoryImpl);
			
			delete.SetTableName("test_delete_builder");

			
			delete.SetIdentityColumn(new string[] {"decimalColumn"}, NHibernateUtil.Decimal);
			delete.SetVersionColumn(new string[] {"versionColumn"}, (IVersionType)NHibernateUtil.Int32);

			delete.AddWhereFragment("a=b");
			SqlString sqlString = delete.ToSqlString();
			Parameter[] actualParams = new Parameter[2];
			int numOfParameters = 0;
			

			string expectedSql = "DELETE FROM test_delete_builder WHERE decimalColumn = :decimalColumn AND versionColumn = :versionColumn AND a=b";
			Assert.AreEqual(expectedSql , sqlString.ToString(), "SQL String");
			
			foreach(object part in sqlString.SqlParts) {
				if(part is Parameter) {
					actualParams[numOfParameters] = (Parameter)part;
					numOfParameters++;
				}
			}
			Assert.AreEqual(2, numOfParameters, "Two parameters");


			Parameter firstParam = new Parameter( "decimalColumn", new SqlTypes.DecimalSqlType() );
			
			Parameter secondParam = new Parameter( "versionColumn", new SqlTypes.Int32SqlType());
			
			Assert.AreEqual(firstParam.SqlType.DbType, actualParams[0].SqlType.DbType, "firstParam Type");
			Assert.AreEqual(firstParam.Name, actualParams[0].Name, "firstParam Name");

			Assert.AreEqual(secondParam.SqlType.DbType, actualParams[1].SqlType.DbType, "secondParam Type");
			Assert.AreEqual(secondParam.Name, actualParams[1].Name, "secondParam Name");

			
				
		}
		protected virtual SqlCommandInfo GenerateDeleteString(int j)
		{
			var deleteBuilder = new SqlDeleteBuilder(Factory.Dialect, Factory);
			deleteBuilder
				.SetTableName(GetTableName(j))
				.SetIdentityColumn(GetKeyColumns(j), IdentifierType);

			// NH: Only add version to where clause if optimistic lock mode is Version
			if (j == 0 && IsVersioned && entityMetamodel.OptimisticLockMode == Versioning.OptimisticLock.Version)
			{
				deleteBuilder.SetVersionColumn(new[] { VersionColumnName }, VersionType);
			}

			if (Factory.Settings.IsCommentsEnabled)
			{
				deleteBuilder.SetComment("delete " + EntityName);
			}
			return deleteBuilder.ToSqlCommandInfo();
		}
        protected SqlCommandInfo GenerateDeleteString(int j)
        {
            SqlDeleteBuilder deleteBuilder = new SqlDeleteBuilder(Factory.Dialect, Factory);
            deleteBuilder
                .SetTableName(GetTableName(j))
                .SetIdentityColumn(GetKeyColumns(j), IdentifierType);

            if (j == 0 && IsVersioned)
            {
                deleteBuilder.SetVersionColumn(new string[] { VersionColumnName }, VersionType);
            }

            if (Factory.Settings.IsCommentsEnabled)
            {
                deleteBuilder.SetComment("delete " + EntityName);
            }
            return deleteBuilder.ToSqlCommandInfo();
        }
		// Generate all the SQL

		/// <summary>
		/// Generate the SQL that deletes rows by id (and version)
		/// </summary>
		/// <returns>An array of SqlStrings</returns>
		protected virtual SqlString[ ] GenerateDeleteStrings()
		{
			SqlString[ ] deleteStrings = new SqlString[ naturalOrderTableNames.Length ];

			for( int i = 0; i < naturalOrderTableNames.Length; i++ )
			{
				SqlDeleteBuilder deleteBuilder = new SqlDeleteBuilder( factory );

				// TODO: find out why this is using tableKeyColumns and when
				// they would ever be different between the two tables - I thought
				// a requirement of Hibernate is that joined/subclassed tables
				// had to have the same pk - otherwise you had an association.
				deleteBuilder.SetTableName( naturalOrderTableNames[ i ] )
					.SetIdentityColumn( naturalOrderTableKeyColumns[ i ], IdentifierType );

				if( i == 0 && IsVersioned )
				{
					deleteBuilder.SetVersionColumn( new string[ ] {VersionColumnName}, VersionType );
				}

				deleteStrings[ i ] = deleteBuilder.ToSqlString();
			}

			return deleteStrings;
		}