I want to implement function that return list of child items from database asynchronously. So I write a function:
public async Task<IEnumerable<object>> GetFiles(int parentId)
{
var data = from file in DB.Files
where file.ParentId == parentId
select new { name = file.Name, id = file.Id };
return data;
}
However I can see a warning: Async method lasks 'await' operators and will run synchronously. How to rewrite this function into asynchronous?
await, and then let it grow from there. In other words, use something likeToListAsyncbefore you mark the methodasync.