OnLogExecuting 只捕获到select查询,update没有捕获到是为什么 返回

SqlSugar 沟通中
1 312
该叫什么 rookie 发布于2026/5/8
悬赏:0 飞吻

动态多租户的实现中,通过配置aop已经可以捕获到select查询输出,但update 没有捕获到是为什么?(注:update语句已经成功执行,只是没有捕获到)


配置时 ↓↓

db.AddConnection(tconnconfig);

var bizDb = db.GetConnectionScope("t");

SetSqlSugarClientAop(bizDb);


... ...


private void SetSqlSugarClientAop(ISqlSugarClient db)

{

    db.Aop.OnLogExecuting = (sql, parameters) =>

    {

        Console.WriteLine(UtilMethods.GetSqlString(db.CurrentConnectionConfig.DbType, sql, parameters));

    };

}


使用时 ↓↓

await repository.AsUpdateable(systemConfig)

                .UpdateColumns(c => c.Pvalue)

                .UpdateColumns(c => c.Modifytime)

                .Where(c=>c.Pvalue == "1")

                .ExecuteCommandAsync();


热忱回答1

  • rookie rookie VIP0
    2026/5/9

    找到问题了,是我仓储中的EntityContext取错了,没事了

    0 回复