/// <summary> Generate the SQL that inserts a row</summary> protected virtual SqlCommandInfo GenerateInsertString(bool identityInsert, bool[] includeProperty, int j) { // todo : remove the identityInsert param and variations; // identity-insert strings are now generated from generateIdentityInsertString() SqlInsertBuilder builder = new SqlInsertBuilder(Factory).SetTableName(GetTableName(j)); // add normal properties for (int i = 0; i < entityMetamodel.PropertySpan; i++) { if (includeProperty[i] && IsPropertyOfTable(i, j)) { // this property belongs on the table and is to be inserted builder.AddColumns(GetPropertyColumnNames(i), propertyColumnInsertable[i], PropertyTypes[i]); } } // add the discriminator if (j == 0) { AddDiscriminatorToInsert(builder); } // add the primary key if (j == 0 && identityInsert) { builder.AddIdentityColumn(GetKeyColumns(0)[0]); } else { builder.AddColumns(GetKeyColumns(j), null, IdentifierType); } if (Factory.Settings.IsCommentsEnabled) { builder.SetComment("insert " + EntityName); } // append the SQL to return the generated identifier if (j == 0 && identityInsert && UseInsertSelectIdentity()) { SqlString sql = builder.ToSqlString(); return new SqlCommandInfo(Factory.Dialect.AppendIdentitySelectToInsert(sql), builder.GetParametersTypeArray()); } return builder.ToSqlCommandInfo(); }