My knowledge around async behaviour in C# is a little rusty and I'm wondering whether changing some code to by async will be of benefit to us or whether it may in fact reduce the efficiency of the code.
I have a collection of methods that each execute a stored procedure through entity framework. We return an IEnumerable<SomeDataType>.
Each method in this collection can run independently of the others and so I got to thinking about running them in parallel.
Something a former colleague told me about DB queries all running synchronously, and wrapping DB calling code in Tasks slowing down the system, popped into my head.
- Can there be benefits to wrapping DB calling code in Tasks? or...
- Will I end up slowing our system down by wrapping DB calls in Tasks?
- Are DB queries all executed in a synchronous fashion?
Our methods look like this:
private IEnumerable<Models.Permission> PermissionsForUser(Context entities,int userId)
{
var userperms = entities.sssp_GetUserPermissions(userId);
return ...
}