public async Task <TResult> ExecuteQueryAsync <TResult>(IQuery <TResult> query) { using (var scope = BillsCompositionRoot.BeginLifetimeScope()) { var mediator = scope.Resolve <IMediator>(); return(await mediator.Send(query)); } }
public static void Initialize( string connectionString, ILoggerFactory loggerFactory, IExecutionContextAccessor executionContext) { var builder = new ContainerBuilder(); builder.RegisterModule(new MediatorModule()); builder.RegisterModule(new ProcessingModule()); builder.RegisterModule(new DataAccessModule(connectionString, loggerFactory)); builder.RegisterModule(new MappingModule()); builder.RegisterInstance(executionContext); builder.Register <ServiceFactory>(context => { var c = context.Resolve <IComponentContext>(); return(t => c.Resolve(t)); }); BillsCompositionRoot.SetContainer(builder.Build()); }