public static InsertStatement CreateInsertStatement(IMapping mapping, bool identityInsert = false) { InsertStatement statement = new InsertStatement(mapping.TableName); statement.IdentityColumnName = String.Empty; foreach (var item in mapping.Columns) { if (item.IsDbGenerated && !identityInsert) { statement.IdentityColumnName = item.Name; } else { var pinfo = (PropertyInfo)item.Property; SqlParameter prm; if (pinfo.PropertyType.IsGenericType && pinfo.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>)) { prm = statement.CreateParameter(item.Name, pinfo.PropertyType.GetGenericArguments()[0]); } else { prm = statement.CreateParameter(item.Name, pinfo.PropertyType); } if (item.IsNullable && item.DefaultValue != null && prm.Value == null) { prm.Value = item.DefaultValue; } statement.Column(item.ColumnName, prm); } } return(statement); }