From ca91e77a1592983b8010867df11890ad9530971d Mon Sep 17 00:00:00 2001 From: maldworth Date: Tue, 19 May 2020 08:10:16 -0400 Subject: [PATCH] Fix DbContext Registration for Activities --- .../Activities/CancelOrder/CancelOrderActivity.cs | 4 +++- .../Activities/SuspendOrder/SuspendOrderActivity.cs | 4 +++- src/SampleBatch.Service/Program.cs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/SampleBatch.Components/Activities/CancelOrder/CancelOrderActivity.cs b/src/SampleBatch.Components/Activities/CancelOrder/CancelOrderActivity.cs index f4c3ff5..7c042bd 100644 --- a/src/SampleBatch.Components/Activities/CancelOrder/CancelOrderActivity.cs +++ b/src/SampleBatch.Components/Activities/CancelOrder/CancelOrderActivity.cs @@ -10,10 +10,12 @@ public class CancelOrderActivity : IExecuteActivity { + private readonly SampleBatchDbContext _dbContext; readonly ILogger _logger; - public CancelOrderActivity(ILoggerFactory loggerFactory) + public CancelOrderActivity(SampleBatchDbContext dbContext, ILoggerFactory loggerFactory) { + _dbContext = dbContext; _logger = loggerFactory.CreateLogger(); } diff --git a/src/SampleBatch.Components/Activities/SuspendOrder/SuspendOrderActivity.cs b/src/SampleBatch.Components/Activities/SuspendOrder/SuspendOrderActivity.cs index 8a470e7..8cc1938 100644 --- a/src/SampleBatch.Components/Activities/SuspendOrder/SuspendOrderActivity.cs +++ b/src/SampleBatch.Components/Activities/SuspendOrder/SuspendOrderActivity.cs @@ -10,10 +10,12 @@ public class SuspendOrderActivity : IExecuteActivity { + private readonly SampleBatchDbContext _dbContext; readonly ILogger _logger; - public SuspendOrderActivity(ILoggerFactory loggerFactory) + public SuspendOrderActivity(SampleBatchDbContext dbContext, ILoggerFactory loggerFactory) { + _dbContext = dbContext; _logger = loggerFactory.CreateLogger(); } diff --git a/src/SampleBatch.Service/Program.cs b/src/SampleBatch.Service/Program.cs index bee937f..feec0c6 100644 --- a/src/SampleBatch.Service/Program.cs +++ b/src/SampleBatch.Service/Program.cs @@ -84,7 +84,7 @@ static async Task Main(string[] args) cfg.AddBus(ConfigureBus); }); - services.AddDbContext(x => x.UseSqlServer(hostContext.Configuration.GetConnectionString("sample-batch"))); + services.AddDbContext(x => x.UseSqlServer(hostContext.Configuration.GetConnectionString("sample-batch"))); services.AddHostedService();