diff --git a/FreeSql/Internal/CommonProvider/UpdateProvider.cs b/FreeSql/Internal/CommonProvider/UpdateProvider.cs index 4d8ab3c9..2b1551db 100644 --- a/FreeSql/Internal/CommonProvider/UpdateProvider.cs +++ b/FreeSql/Internal/CommonProvider/UpdateProvider.cs @@ -777,6 +777,38 @@ namespace FreeSql.Internal.CommonProvider } return this; } + public IUpdate SetDtoIgnoreNull(object dto) + { + if (dto == null) return this; + if (dto is Dictionary) + { + var dic = dto as Dictionary; + foreach (var kv in dic) + { + if (kv.Value == null) + { + continue; + } + if (_table.ColumnsByCs.TryGetValue(kv.Key, out var trycol) == false) continue; + if (_ignore.ContainsKey(trycol.Attribute.Name)) continue; + SetPriv(trycol, kv.Value); + } + return this; + } + var dtoProps = dto.GetType().GetProperties(); + foreach (var dtoProp in dtoProps) + { + var v3 = dtoProp.GetValue(dto, null); + if (v3 == null) + { + continue; + } + if (_table.ColumnsByCs.TryGetValue(dtoProp.Name, out var trycol) == false) continue; + if (_ignore.ContainsKey(trycol.Attribute.Name)) continue; + SetPriv(trycol, v3); + } + return this; + } public IUpdate Where(Expression> exp) => WhereIf(true, exp); public IUpdate WhereIf(bool condition, Expression> exp)