SqlSugar C#代码中批量更新时报错:You cannot have no primary key and no conditions

问题:使用SqlSugar批量更新时报错“SqlSugar.SqlSugarException: You cannot have no primary key and no conditions”;

  主键或条件不存在

  Db.Updateable<User>(users).ExecuteCommand();

解决办法

  就是用WhereColumns指定条件,无主键更新

  Db.Updateable<User>(users).WhereColumns(it => new { it.Id }).ExecuteCommand();

posted @ 2021-09-30 11:36  一纸年华  阅读(3588)  评论(0编辑  收藏  举报