Skip to content

Commit caccc8d

Browse files
committed
Fixed V1 testing issue
1 parent ad8e2a3 commit caccc8d

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/EntityFrameworkCore.Triggered/Infrastructure/Internal/TriggersOptionExtension.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,7 @@ public void ApplyServices(IServiceCollection services)
180180

181181
var instanceParamExpression = Expression.Parameter(typeof(object), "object");
182182

183-
var triggerInstanceFactoryBuilder =
184-
Expression.Lambda<Func<object?, object>>(
185-
Expression.New(
186-
typeof(TriggerInstanceFactory<>).MakeGenericType(triggerServiceType).GetConstructor(new[] { typeof(object) }),
187-
instanceParamExpression
188-
),
189-
instanceParamExpression
190-
)
191-
.Compile();
183+
Func<object?, object>? triggerInstanceFactoryBuilder = null;
192184

193185
foreach (var triggerType in _triggerTypes.Distinct())
194186
{
@@ -198,6 +190,19 @@ public void ApplyServices(IServiceCollection services)
198190

199191
foreach (var triggerTypeImplementation in triggerTypeImplementations)
200192
{
193+
if (triggerInstanceFactoryBuilder is null)
194+
{
195+
triggerInstanceFactoryBuilder =
196+
Expression.Lambda<Func<object?, object>>(
197+
Expression.New(
198+
typeof(TriggerInstanceFactory<>).MakeGenericType(triggerServiceType).GetConstructor(new[] { typeof(object) }),
199+
instanceParamExpression
200+
),
201+
instanceParamExpression
202+
)
203+
.Compile();
204+
}
205+
201206
var triggerTypeImplementationFactoryType = typeof(ITriggerInstanceFactory<>).MakeGenericType(triggerTypeImplementation);
202207
services.Add(new ServiceDescriptor(triggerTypeImplementationFactoryType, _ => triggerInstanceFactoryBuilder(triggerServiceInstance), lifetime));
203208
}

test/EntityFrameworkCore.Triggered.IntegrationTests/ApplicationDbContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace EntityFrameworkCore.Triggered.IntegrationTests
1010
{
11-
public class ApplicationDbContext : DbContext
11+
public class ApplicationDbContext : TriggeredDbContext
1212
{
1313
readonly string _databaseName;
1414

0 commit comments

Comments
 (0)