public override void PrepareUpdateStatement(IDbCommand dbCmd, T item, bool excludeDefaults = false) { CopyParamsTo(dbCmd); var setFields = StringBuilderCache.Allocate(); foreach (var fieldDef in ModelDef.FieldDefinitions) { if (UpdateFields.Count > 0 && !UpdateFields.Contains(fieldDef.Name) || fieldDef.AutoIncrement) { continue; // added } var value = fieldDef.GetValue(item); if (excludeDefaults && (value == null || (!fieldDef.IsNullable && value.Equals(value.GetType().GetDefaultValue())))) { continue; } if (setFields.Length > 0) { setFields.Append(", "); } var param = DialectProvider.AddUpdateParam(dbCmd, value, fieldDef); setFields .Append(DialectProvider.GetQuotedColumnName(fieldDef.FieldName)) .Append("=") .Append(param.ParameterName); } var strFields = StringBuilderCache.ReturnAndFree(setFields); if (strFields.Length == 0) { throw new ArgumentException("No non-null or non-default values were provided for type: " + typeof(T).Name); } dbCmd.CommandText = $"UPDATE {DialectProvider.GetQuotedTableName(ModelDef)} SET {strFields} {WhereExpression}"; }