Skip to content

Commit

Permalink
avoid calling wait on a task
Browse files Browse the repository at this point in the history
  • Loading branch information
hahn-kev committed Jan 14, 2025
1 parent 617d644 commit bea2c31
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,15 @@ public async Task BulkCreateEntries(IAsyncEnumerable<Entry> entries)
var semanticDomains = await SemanticDomains.ToDictionaryAsync(sd => sd.Id, sd => sd);
var partsOfSpeech = await PartsOfSpeech.ToDictionaryAsync(p => p.Id, p => p);
await dataModel.AddChanges(ClientId,
entries.ToBlockingEnumerable()
.SelectMany(entry =>
await entries.SelectAwait(async entry =>
{
validators.ValidateAndThrow(entry).Wait(); //?
return CreateEntryChanges(entry, semanticDomains, partsOfSpeech);
await validators.ValidateAndThrow(entry);
return entry;
})
.SelectMany(entry => CreateEntryChanges(entry, semanticDomains, partsOfSpeech).ToAsyncEnumerable())
//force entries to be created first, this avoids issues where references are created before the entry is created
.OrderBy(c => c is CreateEntryChange ? 0 : 1)
.ToArrayAsync()
);
}

Expand Down

0 comments on commit bea2c31

Please sign in to comment.