Skip to content

Commit 4f28cb7

Browse files
committed
Don't open Factory, when nothing to delete
1 parent 9c3e2b6 commit 4f28cb7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/LinkDotNet.Blog.Infrastructure/Persistence/Sql/Repository.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ public async ValueTask StoreAsync(TEntity entity)
7878

7979
public async ValueTask DeleteAsync(string id)
8080
{
81-
await using var blogDbContext = await dbContextFactory.CreateDbContextAsync();
8281
var entityToDelete = await GetByIdAsync(id);
8382
if (entityToDelete != null)
8483
{
84+
await using var blogDbContext = await dbContextFactory.CreateDbContextAsync();
8585
blogDbContext.Remove(entityToDelete);
8686
await blogDbContext.SaveChangesAsync();
8787
}

0 commit comments

Comments
 (0)