I would like to ask about "using" statement in Entity Framework. As I saw several time in other forums and books, that it's a good practice when you are quering database using following code (from ASP.NET MVC4 Appliocation):
using (var db = new ProductsEntites())
{
var result = db.Products.ToList();
return View(result);
}
But in other hand, if we are using scaffolding to generate contorller methods and view, default generator is declaring
private ProductsEntites db = new ProductsEntites()
at controller level, so in this case memory that are used to store query results are released only when timeout usage expired and garbage collector unlock memory for other needs. So what is better for small web site and what is best for big