예제 #1
0
        public async Task <IEnumerable <Speaker>?> GetSpeakersAsync(
            [ScopedService] ApplicationDbContext dbContext,
            SpeakerByIdDataLoader speakerById,
            CancellationToken cancellationToken)
        {
            if (Session is null)
            {
                return(null);
            }

            int[] speakerIds = await dbContext.Sessions
                               .Where(s => s.Id == Session.Id)
                               .Include(s => s.SessionSpeakers)
                               .SelectMany(s => s.SessionSpeakers.Select(t => t.SpeakerId))
                               .ToArrayAsync();

            return(await speakerById.LoadAsync(speakerIds, cancellationToken));
        }
예제 #2
0
 public Task <Speaker> GetSpeakerAsync(
     [ID(nameof(Speaker))] int id,
     SpeakerByIdDataLoader dataLoader,
     CancellationToken cancellationToken)
 => dataLoader.LoadAsync(id, cancellationToken);
예제 #3
0
 public async Task <IEnumerable <Speaker> > GetSpeakersByIdAsync(
     [ID(nameof(Speaker))] int[] ids,
     SpeakerByIdDataLoader dataLoader,
     CancellationToken cancellationToken) =>
 await dataLoader.LoadAsync(ids, cancellationToken);
예제 #4
0
            public async Task <IEnumerable <Speaker> > GetSpeakersAsync(Session session,
                                                                        [ScopedService] ApplicationDbContext dbContext, SpeakerByIdDataLoader speakerByIdDataLoader,
                                                                        CancellationToken cancellationToken)
            {
                var speakersIds = await dbContext.Sessions.Where(s => s.Id == session.Id)
                                  .Include(s => s.SessionSpeakers)
                                  .SelectMany(s => s.SessionSpeakers.Select(t => t.SpeakerId))
                                  .ToArrayAsync(cancellationToken);

                return(await speakerByIdDataLoader.LoadAsync(speakersIds, cancellationToken));
            }
예제 #5
0
 public Task <Speaker> GetSpeakerAsync(
     SpeakerByIdDataLoader speakerById,
     int id,
     CancellationToken cancellationToken) =>
 speakerById.LoadAsync(id, cancellationToken);
예제 #6
0
 public Task <IReadOnlyList <Speaker> > GetSpeakersByIdAsync(
     [ID(nameof(Speaker))] long[] ids,
     SpeakerByIdDataLoader dataLoader,
     CancellationToken cancellationToken) =>
 dataLoader.LoadAsync(ids, cancellationToken);
예제 #7
0
 public Task <Speaker> GetSpeaker(Guid id, SpeakerByIdDataLoader dataLoader, CancellationToken cancellationToken) => dataLoader.LoadAsync(id, cancellationToken);