更新就报错 返回
xiedashan 发布于2025/8/29
SqlSugar.SqlSugarException:“中文提示 : 乐观锁只能是Guid、Long和字符串类型
English Message : Optimistic locks can only be guid, long, and string types”
[SqlSugar.SugarColumn(IsEnableUpdateVersionValidation = true)]//标识版本字段
public byte[] UpdateVersion { get; set; }
热忱回答(9)
-
fate sta VIP0
2025/8/29https://www.donet5.com/Home/Doc?typeId=2399
看文档:2.2 ,你应该按2.2去写
0 回复 -
fate sta VIP0
2025/8/29还有疑问提供完整的DEMO
0 回复 -
xiedashan VIP0
2025/8/29@fate sta:
public int updateFeeById(Fee f)
{
return ConnectionFactory.HGDb.Updateable(f)
.Where(e => e.ID == f.ID)
.IgnoreColumns(e => new { e.OpAudit, e.TimeAudit
})
.ExecuteCommandWithOptLock(true);
}
[SqlSugar.SugarColumn(IsEnableUpdateVersionValidation = true)]//标识版本字段
public string UpdateVersion { get; set; }
0 回复 -
xiedashan VIP0
2025/8/29@fate sta:version 换成string类型 不允许从数据类型 nvarchar 到 timestamp 的隐式转换。请使用 CONVERT 函数来运行此查询
0 回复 -
xiedashan VIP0
2025/8/29@fate sta:我用2.1写的....
0 回复 -
fate sta VIP0
2025/8/29你不是sqlserver你实体用Byte[]做什么
0 回复 -
xiedashan VIP0
2025/9/1@fate sta:我就是sqlserver数据库
0 回复 -
fate sta VIP0
2025/9/1还有疑问提供DEMO, 目前2.2是完全可以的。
0 回复 -
fate sta VIP0
2025/9/1必须2.2 。
0 回复