EntityFramework.Triggers icon indicating copy to clipboard operation
EntityFramework.Triggers copied to clipboard

question re async

Open ericsampson opened this issue 1 year ago • 2 comments

Hi, love this library!

What's the right way to use async code in the trigger body? Like this pseudo-code example:

configure.Triggers<Order, dbContext>().Inserted
                    .Add<(IEmitter Emitter, IDepotOrderRepository OrderRepository)>(
                    async entry =>
                    {
                        var foo = await OrderRepository.DoSomething();
                        await Emitter.Emit(foo);
                        Console.WriteLine($"The value of foo is: {foo}");
                     }
);

ericsampson avatar Feb 29 '24 18:02 ericsampson

That's pretty much it, yep. It's missing CancellationToken support for now.

NickStrupat avatar Mar 09 '24 04:03 NickStrupat

So the issue I'm getting is coming from SimpleInjector. Any thoughts on how I can resolve this? Cheers!

SimpleInjector.ActivationException: DepotOrderRepository is registered using the 'Async Scoped' lifestyle, but the instance is requested outside the context of an active (Async Scoped) scope.

ericsampson avatar Jul 22 '24 18:07 ericsampson