/// <summary>
        /// Generate the SQL that inserts a row
        /// </summary>
        /// <param name="identityInsert"></param>
        /// <param name="includeProperty"></param>
        /// <returns>A SqlString for an Insert</returns>
        protected virtual SqlString GenerateInsertString(bool identityInsert, bool[] includeProperty)
        {
            SqlInsertBuilder builder = new SqlInsertBuilder(factory)
                                       .SetTableName(TableName);

            for (int i = 0; i < HydrateSpan; i++)
            {
                if (includeProperty[i])
                {
                    builder.AddColumn(propertyColumnNames[i], PropertyTypes[i]);
                }
            }

            if (discriminatorInsertable)
            {
                builder.AddColumn(DiscriminatorColumnName, DiscriminatorSQLValue.ToString());
            }

            if (!identityInsert)
            {
                builder.AddColumn(IdentifierColumnNames, IdentifierType);
            }
            else
            {
                // make sure the Dialect has an identity insert string because we don't want
                // to add the column when there is no value to supply the SqlBuilder
                if (Dialect.IdentityInsertString != null)
                {
                    // only 1 column if there is IdentityInsert enabled.
                    builder.AddColumn(IdentifierColumnNames[0], Dialect.IdentityInsertString);
                }
            }

            return(builder.ToSqlString());
        }
        public void Commented()
        {
            Configuration   cfg     = new Configuration();
            ISessionFactory factory = cfg.BuildSessionFactory();

            ISessionFactoryImplementor factoryImpl = (ISessionFactoryImplementor)factory;
            SqlInsertBuilder           insert      = new SqlInsertBuilder(factoryImpl);

            insert.SetTableName("test_insert_builder");

            insert.AddColumn("stringColumn", "aSQLValue", (ILiteralType)NHibernateUtil.String);
            insert.SetComment("Test insert");
            string expectedSql =
                "/* Test insert */ INSERT INTO test_insert_builder (stringColumn) VALUES ('aSQLValue')";

            Assert.AreEqual(expectedSql, insert.ToSqlString().ToString(), "SQL String");
        }
        /// <summary>
        /// Generate the SQL INSERT that creates a new row
        /// </summary>
        /// <returns></returns>
        protected override SqlString GenerateInsertRowString()
        {
            SqlInsertBuilder insert = new SqlInsertBuilder(factory)
                                      .SetTableName(qualifiedTableName)
                                      .AddColumn(KeyColumnNames, KeyType);

            if (HasIndex)
            {
                insert.AddColumn(IndexColumnNames, IndexType);
            }
            if (hasIdentifier)
            {
                insert.AddColumn(new string[] { identifierColumnName }, IdentifierType);
            }
            insert.AddColumn(ElementColumnNames, ElementType);

            return(insert.ToSqlString());
        }