i was reading a article on Asynchronous ASP.NET Core 2 Web API from this web sitehttp://www.mithunvp.com/fully-asynchronous-aspnet-core-2-web-api/
the author show with code that how to develop Asynchronous ASP.NET Core 2 Web API.
here is the code snippet
[HttpGet] public async Task<IActionResult> GetAll() { var contactList = await ContactsRepo.GetAll(); return Ok(contactList); }
public class ContactsRepository : IContactsRepository { ContactsContext _context; public ContactsRepository(ContactsContext context) { _context = context; } public async Task Add(Contacts item) { await _context.Contacts.AddAsync(item); await _context.SaveChangesAsync(); } public async Task<IEnumerable<Contacts>> GetAll() { return await _context.Contacts.ToListAsync(); } //Code removed for brevity }
another guy said for the above code
You don’t need async/await in GetAll(), it creates unnecessary empty continuation. However since Task is not covariant you’ll have to change the method’s signature. And that’s good because Task<IEnumerable> is no really good return type.
anyone can share the knowledge that why some one said GetAll(), it creates unnecessary empty continuation ?
also said Task<IEnumerable> is no really good return type
please some one clear the points what other person try to say.
what is wrong in the above code ?
please discuss in details. thanks