I\'m writing some code to access a database using EntityFrameWork. The code is:
public IEnumerable GetRows(int id)
{
using (var context = new
Without ToList() you only return enumerator not actual collection of objects. The actual objects are fetched when you try to access the collection. But in this case what you need is a context and repository, because you accessing them from the database. But since it's already out of scope of the using clause both are disposed hence the exception.