dotnetcore / SmartSql

SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics
https://smartsql.net/
Apache License 2.0
1.1k stars 222 forks source link

AOP事务判断事务状态 #59

Closed XiaoHeitu closed 5 years ago

XiaoHeitu commented 5 years ago

在主方法和子方法都存在TransactionAttribute 的情况下。会出异常。AspectCore.DynamicProxy.AspectInvocationException: Exception has been thrown by the aspect of an invocation. ---> Before RollbackTransaction,Please BeginTransaction first!. ---> SmartSql.Exceptions.SmartSqlException: Before RollbackTransaction,Please BeginTransaction first!

如果能在 Invoke 里面判断一下当前事务状态话,在事务已经Begin之后就不要再操作事务了。这样应该可以解决这个问题。

Ahoo-Wang commented 5 years ago

你可以选择提交一下PR

Ahoo-Wang commented 5 years ago

Ref https://github.com/Smart-Kit/SmartSql/commit/4255778974d6c7a761a3121b4fe6e12c9a47b933