Skip to content

Commit

Permalink
Reduce the number of entities in the sample app data seeder.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdlcf88 committed Aug 20, 2021
1 parent 00ab332 commit 9fcee62
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Guids;
using Volo.Abp.Uow;

namespace DynamicEntitySample.DynamicEntities
{
Expand All @@ -25,6 +26,7 @@ public DynamicEntityDataSeedContributor(IFieldDefinitionRepository fieldDefiniti
_guidGenerator = guidGenerator;
}

[UnitOfWork]
public async Task SeedAsync(DataSeedContext context)
{
var fdPrice = await _fieldDefinitionRepository.FindAsync(fd => fd.Name == "price");
Expand Down Expand Up @@ -62,7 +64,7 @@ public async Task SeedAsync(DataSeedContext context)
var rams = new[] {"4GB", "8GB", "16GB", "32GB"};
var prices = new[] {"999", "1999", "2999", "3999"};
var rnd = new Random();
for (int i = 0; i < 30000; i++)
for (int i = 0; i < 3000; i++)
{
var entity = new DynamicEntity(_guidGenerator.Create()).SetModelDefinition(mdComputer.Id);
entity.SetProperty("cpu", cpus[rnd.Next() % cpus.Length]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.Uow;

namespace EasyAbp.Abp.DynamicEntity
{
Expand All @@ -27,6 +28,7 @@ public DynamicEntityDataSeedContributor(
_dynamicEntityRepository = dynamicEntityRepository;
}

[UnitOfWork]
public async Task SeedAsync(DataSeedContext context)
{
/* Instead of returning the Task.CompletedTask, you can insert your test data
Expand Down

0 comments on commit 9fcee62

Please sign in to comment.