Skip to content

Commit

Permalink
Added IDisposable to bot-repository
Browse files Browse the repository at this point in the history
  • Loading branch information
szv committed Jun 29, 2023
1 parent c943df2 commit c15d494
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/Services/Bot/src/Data/Repositories/BotRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
using CodeBreaker.Services.Bot.Data.Models.Extensions;
using CodeBreaker.Services.Bot.Data.Repositories.Args;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query;

namespace CodeBreaker.Services.Bot.Data.Repositories;

public class BotRepository(BotDbContext dbContext) : IBotRepository
public class BotRepository(BotDbContext dbContext) : IBotRepository, IDisposable
{
public IAsyncEnumerable<Models.Bot> GetBotsAsync(GetBotsArgs args) =>
dbContext.Bots
Expand Down Expand Up @@ -42,4 +41,9 @@ await queryable.ExecuteUpdateAsync(x => x
else
await queryable.ExecuteUpdateAsync(x => x.SetProperty(bot => bot.State, newState), cancellationToken);
}

public void Dispose()
{
dbContext.Dispose();
}
}
2 changes: 1 addition & 1 deletion src/Services/Bot/src/Data/Repositories/IBotRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using CodeBreaker.Services.Bot.Data.Repositories.Args;

namespace CodeBreaker.Services.Bot.Data.Repositories;
public interface IBotRepository
public interface IBotRepository : IDisposable
{
Task<Models.Bot> CreateAsync(Models.Bot bot, CancellationToken cancellationToken = default);
Task<Models.Bot> GetBotAsync(Guid id, CancellationToken cancellationToken);
Expand Down

0 comments on commit c15d494

Please sign in to comment.