maliming
4 years ago
No known key found for this signature in database
GPG Key ID: 96224957E51C89E
1 changed files with
16 additions and
11 deletions
-
framework/src/Volo.Abp.Data/Volo/Abp/Data/DataSeeder.cs
|
|
|
@ -25,20 +25,25 @@ public class DataSeeder : IDataSeeder, ITransientDependency |
|
|
|
{ |
|
|
|
using (var scope = ServiceScopeFactory.CreateScope()) |
|
|
|
{ |
|
|
|
var manager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>(); |
|
|
|
foreach (var contributorType in Options.Contributors) |
|
|
|
if (context.Properties.ContainsKey(nameof(DataSeederExtensions.SeedInSeparateUowAsync))) |
|
|
|
{ |
|
|
|
using (var uow = manager.Begin( |
|
|
|
requiresNew: context.Properties.ContainsKey(nameof(DataSeederExtensions.SeedInSeparateUowAsync)), |
|
|
|
isTransactional: true)) |
|
|
|
var manager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>(); |
|
|
|
foreach (var contributorType in Options.Contributors) |
|
|
|
{ |
|
|
|
var contributor = (IDataSeedContributor)scope |
|
|
|
.ServiceProvider |
|
|
|
.GetRequiredService(contributorType); |
|
|
|
|
|
|
|
using (var uow = manager.Begin(requiresNew: true, isTransactional: true)) |
|
|
|
{ |
|
|
|
var contributor = (IDataSeedContributor)scope.ServiceProvider.GetRequiredService(contributorType); |
|
|
|
await contributor.SeedAsync(context); |
|
|
|
await uow.CompleteAsync(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
foreach (var contributorType in Options.Contributors) |
|
|
|
{ |
|
|
|
var contributor = (IDataSeedContributor)scope.ServiceProvider.GetRequiredService(contributorType); |
|
|
|
await contributor.SeedAsync(context); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|