DotNetNext / SqlSugar

.Net aot ORM Fastest ORM Simple Easy VB.NET Sqlite orm Oracle ORM Mysql Orm 虚谷数据库 postgresql ORm SqlServer oRm 达梦 ORM 人大金仓 ORM 神通ORM C# ORM , C# ORM .NET ORM NET5 ORM .NET6 ORM ClickHouse orm QuestDb ,TDengine ORM,OceanBase orm,GaussDB orm ,Tidb orm Object/Relational Mapping
https://www.donet5.com/Home/Doc
MIT License
5.35k stars 1.34k forks source link

SetColumnsIF 如果全部未达成会导致更新所有字段 #929

Closed AFKLin closed 3 years ago

AFKLin commented 3 years ago
        _gUserDal.Db.Updateable<GUser>()
            .SetColumnsIF(!dto.NickName.IsNullOrEmpty(), c => c.NickName == dto.NickName)
            .SetColumnsIF(dto.BirthdayTime != null, c => c.BirthdayTime == dto.BirthdayTime)
            .SetColumnsIF(dto.MainPic != null, c => c.MainPic == dto.MainPic)
            .Where(c => c.GUserId == _gUserId)
            .ExecuteCommand();

如果全部条件都是false 会导致更新所有字段

DotNetNext commented 3 years ago

要保证有一列

DotNetNext commented 3 years ago

不然会报错

AFKLin commented 3 years ago

要保证有一列

这种如果全部条件未达成throw 一个错误或者不更新会稍微好点吧。因为执行之后肯定是错误的预期