Is there a way to specify the isolation level of a transaction in BEEF? #273
-
|
We are using BEEF core version 4 in our application. We would like to set the default isolation level of the TransactionScope to READ COMMITTED. We can see in https://github.com/Avanade/Beef/blob/version-4/src/Beef.Core/Business/BusinessInvokerBase.cs, we can pass argument TransactionScopeOption to WrapInvokeAsync but there appears to be no way to set TransactionOption argument which controls the isolation level. Isolation level in .net by default seems to be Serializable. Commented code below is what we would like to do: Any ideas of how we can do this? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Hi @shirleywesley, yes there is. Within the base protected static TInvoker GetCurrentInstance<TInvoker>(bool throwExceptionOnNull = true) where TInvoker : Invoker => ExecutionContext.GetService<TInvoker>(throwExceptionOnNull)!;The public class ManagerInvoker : BusinessInvokerBase
{
/// <summary>
/// Gets the current configured instance (see <see cref="ExecutionContext.ServiceProvider"/>).
/// </summary>
public static ManagerInvoker Current => GetCurrentInstance<ManagerInvoker>(false) ?? new ManagerInvoker();
}What you'll need to do is create your own The final step is then to register each at startup, i.e. All going well this should work. Note I have not tested this; let me know if you run into any issues as there may be one other option to enable that is a little more heavy handed. Cheers... |
Beta Was this translation helpful? Give feedback.
-
|
Thanks again Eric, that seems to have worked for us! |
Beta Was this translation helpful? Give feedback.

Hi @shirleywesley, yes there is.
Within the base
Invokerthe following code will look to load a genericTInvokerfrom the underlyingIServiceProviderwhere configured, so that represents our runtime replacement opportunity:The
DataInvoker,DataSvcInvokerandManagerInvokerall implement code similar to: