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();

本文来自博客园,作者:一纸年华,转载请注明原文链接:https://www.cnblogs.com/nullcodeworld/p/15356012.html

原文地址:https://www.cnblogs.com/nullcodeworld/p/15356012.html