您当前的位置:首页 > 文章 > SqlSugar C#代码中批量更新时报

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

作者:一纸年华 时间:2023-07-05 阅读数:343 人阅读
问题:使用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();


作者:一纸年华

本站大部分文章、数据、图片均来自互联网,一切版权均归源网站或源作者所有。

如果侵犯了您的权益请来信告知我们删除。邮箱:1451803763@qq.com