ABP框架钟使用Dapper时,HttpPost调用接口报错解决办法

1、Query方法单独测试成功,HttpGet接口调用成功,但是如果是HttpPut或者HttpPost接口调用则会报错[ERR] BeginExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction.  The Transaction property of the command has not been initialized.

临时处理方法:using (IDbConnection connection = DbConnection){

…connection.QueryAsync<T>…

}

改为

DbConnection.QueryAsync<T>

 

 

2、以上方法还是不成功的话,则在controller层的httppost接口加上[UnitOfWork(false, IsolationLevel.ReadCommitted)]属性即可。

 

posted @ 2021-11-05 11:24  奈何碧落黄泉  阅读(671)  评论(1编辑  收藏  举报