I am trying to work out why is the first block of code erroring out and the second block isnt when the only difference is that the first one is using Task and the second block isnt. Looked into various sources but couldnt get clear answer. Anyone knows how to fix the first block?
referred to links below but no luck so far
How to cast DbSet<T> to List<T>
Why DbSet<TEntity> doesn't implement EnumerableAsync
public Task<IEnumerable<Asset>> GetAll()
{
var assets = Task.Factory.StartNew(() => _context.Books);
return assets;
// tried toList<asset>() on "return assets" as well but didnt make any difference.
}
public IEnumerable<Asset> GetAlls()
{
var assets = _context.Books;
return assets;
}