C
C#3mo ago
kr.prem

For WebAPI projects should we go all the way async ?

Working on .NET 5 (just for now) web API, I have Controllers, Service and Repository files. Should I use asynchronous methods in all 3 files from starting to end like a chain. Controller is using Request - Response Model and repository is having DB Model, conversion and other business logics are implemented in the service file.
2 Replies
Pobiega
Pobiega3mo ago
more or less, yes repository implies accessing a database or some other "storage resource", and that almost always involves IO work IO should be async when possible and since async "spreads", that means any service using it must also be async, and thus the controller methods must also be async
kr.prem
kr.prem3mo ago
Thank you for the response