C
C#2y ago
w1tcherr

Await inside a repository for a SELECT request

I was looking at the blazor hero template and in the repository implementation they used await for FindAsync, ToListAsync, etc. I can't understand why they can't just return the Task from these methods? Is it right to await a response from the DB inside the repository?
2 Replies
Anton
Anton2y ago
they can the difference is in the stack trace in case of an exception if you just return the task, it won't show that method in the stack trace
Angius
Angius2y ago
The pointlesness of a generic repo aside, awaiting instead of returning a straight task results in better stack trace
Want results from more Discord servers?
Add your server