Skip to content

Commit

Permalink
used split query
Browse files Browse the repository at this point in the history
  • Loading branch information
skrasekmichael committed Mar 11, 2024
1 parent bb96d9f commit f12691f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ public GetEventQueryHandler(IAppQueryContext appQueryContext)
public async Task<Result<EventResponse>> Handle(GetEventQuery query, CancellationToken ct)
{
var team = await _appQueryContext.Teams
.AsSplitQuery()
.Include(team => team.Members)
.Select(team => new
{
team.Id,
Event = _appQueryContext.Events
.AsSplitQuery()
.Where(e => e.Id == query.EventId && e.TeamId == team.Id)
.Select(e => new EventResponse
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public TeamRepository(ApplicationDbContext context)
public async Task<Team?> GetTeamByIdAsync(TeamId teamId, CancellationToken ct = default)
{
return await _context.Teams
.AsSplitQuery()
.Include(team => team.Members)
.Include(team => team.EventTypes)
.FirstOrDefaultAsync(team => team.Id == teamId, ct);
Expand Down
5 changes: 5 additions & 0 deletions tests/TeamUp.Tests.EndToEnd/AppFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;

Expand Down Expand Up @@ -31,6 +32,10 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)
services.AddDbContext<ApplicationDbContext>(options =>
{
options.UseNpgsql(connectionString);
options.ConfigureWarnings(w =>
{
w.Throw(RelationalEventId.MultipleCollectionIncludeWarning);
});
});

//email
Expand Down

0 comments on commit f12691f

Please # to comment.