In the tutorials for ASP.Net MVC, the LINQ to Entities code looks like:
public class MyController : Controller
{
private Models db;
public ActionResult Index()
{
db = new Models();
var foo = (from f in db.foo select f).ToList();
return View(foo);
}
}
I'm guessing this has something to do with thread safety/connection pooling, but I just wanted to know if anyone knew of any good reasons not to do it this way:
public class MyController : Controller
{
private readonly Models db = new Models();
public ActionResult Index()
{
var foo = (from f in db.foo select f).ToList();
return View(foo);
}
}