或者换一种方式说:国际奥委会在飞行中压倒一切和决议。
我们为一些使用事务的代码注入了基于构造函数的事务对象。在.NETCore中,对于中央IOC配置,这不再是一种明显的工作方式。
由于涉及的依赖项的数量太多,有一种方法是通过方法参数将事务从域传播到DB。这是一个选择,但噪音大,价格昂贵。
事务作用域在我们的情况下不起作用,因为我们如何打开和关闭连接。它们往往被提升为分布式事务,这并不理想。
DomainMethod() // This might be called from a controller [using the default IoC configuration]
{
using (var scope = new Scope())
// add resolver for transaction dependency for just this scope.
var dep1 = ...// resolve a new dependency tree
dep1.Execute(....); // invokes dependency using the modified resolver.
}
}
这是有效的方法吗?
How to create a child scope from the parent with default dependency injection in .NET Core?
在net.asp核心。