审计日志-差异日志功能更新操作时更新后的值取不到 返回

SqlSugar 待处理
1 173

示例值如下:初步判断是更新前后使用了同样的条件查询,但是条件里面的值被变化了

表:Student

列及值

Price CreateTime

0    2026-7-23 16:22:21

执行代码:

db.Updateable<Student>()

          .SetColumns(it => new Student() { Price=1,CreateTime=DateTime.Now}) 

          .Where(it => it.Price =0)

          .ExecuteCommand();

DataExecuting事件得到的修改后的值为null,跟踪的sql语句如下

exec sp_executesql N'SELECT [Price],[CreateTime] FROM [Student]  WHERE ([Price]=@Const0 ) ',N'@Const0 int',@Const0=0

exec sp_executesql N'UPDATE [Student]  SET

[Price] = @Const0 , [CreateTime] = @Const1   WHERE ([Price]=@Const2 )',N'@Const0 int,@Const2 datetime,@zdr3 int',@Const0=1,@Const1='2026-07-23 16:13:32',@Const2=0

exec sp_executesql N'SELECT [Price],[CreateTime] FROM [Student]  WHERE ([Price]=@Const0 ) ',N'@Const0 int',@Const0=0


热忱回答1