How to use Task.WhenAll with NPoco fetchAsync?

47 views Asked by At

I'm trying to use Task.WhenAll. It's not working though because fetchAsync seems to get triggered when i declare classesTask. Any ideas? Using .Net framework 4.7.2 and NPoco

var classesTask = scope.FetchAsync<ClassModel>();
var competitionsTask = scope.FetchAsync<CompetitionDto>();

// Wait for all tasks to complete concurrently
await Task.WhenAll( classesTask, competitionsTask);

// Access the results directly
var classes = await classesTask;
var competitions = await competitionsTask;
0

There are 0 answers