When writing async functions, usually if you do not explicitly writer await
or async
your compiler would throw an error or warning. Example of correct syntax below:
public async Task<List<TEntity>> GetEntitiesAsync() =>
await TEntityRepository.GetAllAsync();
Now the following works still, it is async and returns a Task<List>
public Task<List<TEntity>> GetEntitiesAsync() =>
TEntityRepository.GetAllAsync();
Why does the second one still work
>`. The method `GetAllAsync` presumably also returns a `Task
– RB. Oct 13 '21 at 22:30>` - so why wouldn't it work? It's just a totally normal, bog-standard method at that point - it works for the same reason `public int GetNumber() => 42` works...