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)]属性即可。