5 Commits

Author SHA1 Message Date
Anatolii Grynchuk 9c1da388d8 fix: use GetByIdAsync in DeleteAsync(TEntityId)
Replaced sync GetById with await GetByIdAsync to avoid blocking the thread inside an async method.

Ref: #IT-631
2026-05-06 12:46:35 +03:00
agrynco 1edcafdebd Merge pull request 'fix: eliminate multi-save in batch Add and DeleteAsync(TEntityId)' (#10) from IT-631-fix-delete into development 2026-05-06 12:45:09 +03:00
Anatolii Grynchuk 93461fd35e fix: eliminate multi-save in batch Add and DeleteAsync(TEntityId)
- Add(TEntity[]) now passes save:false in the loop and calls SaveChanges once at the end
- DeleteAsync(TEntityId) now calls DoRemove directly instead of Delete(TEntityId) to avoid the double-save from the sync overload chain

Ref: #IT-631
2026-05-06 12:43:27 +03:00
Anatolii Grynchuk 4020981eec chore: upgrade ef core 8.0.15 -> 10.0.7
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-06 02:20:44 +03:00
Anatolii Grynchuk 2b02374b19 chore: downgrade ef core 9.0.5 -> 8.0.15
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-06 01:55:07 +03:00
2 changed files with 14 additions and 5 deletions
+3 -3
View File
@@ -6,8 +6,8 @@
<!-- HrynCo shared packages --> <!-- HrynCo shared packages -->
<PackageVersion Include="HrynCo.Common" Version="1.0.0" /> <PackageVersion Include="HrynCo.Common" Version="1.0.0" />
<!-- Entity Framework Core --> <!-- Entity Framework Core -->
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.5" /> <PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.7" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.5" /> <PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.7" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.5" /> <PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.7" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+11 -2
View File
@@ -40,7 +40,12 @@ public abstract class BaseEfRepository<TDbContext, TEntity, TEntityId> :
{ {
foreach (TEntity entity in entities) foreach (TEntity entity in entities)
{ {
Add(entity, save); Add(entity, save: false);
}
if (save)
{
DbContext.SaveChanges();
} }
} }
@@ -84,7 +89,11 @@ public abstract class BaseEfRepository<TDbContext, TEntity, TEntityId> :
public async Task DeleteAsync(TEntityId id) public async Task DeleteAsync(TEntityId id)
{ {
Delete(id); TEntity? entity = await GetByIdAsync(id);
if (entity != null)
{
DoRemove(entity);
}
await DbContext.SaveChangesAsync(); await DbContext.SaveChangesAsync();
} }