If I use
// VERSION A
private static IResult Gets(AppDbContext db)
{
var output = db.Courses.AsNoTracking().Select(c => new CourseDto { Id = c.Id, Credits = c.Credits });
return Results.Ok(output);
}
instead of
// VERSION B
private static async Task<IResult> Gets(AppDbContext db)
{
var output = db.Courses.AsNoTracking().Select(c => new CourseDto { Id = c.Id, Credits = c.Credits });
return Results.Ok(await output.ToArrayAsync());
}
does the framework internally invoke one of ToArray(), ToArrayAsync(), ToList() or ToListAsync(), etc (among others) to "materialize" IQueryable<CourseDto> and produce JSON output?
One more question: Which approach should I choose? Version A or version B?