public class AccountController : Controller
{
private readonly mydbcontext db = new mydbcontext();
protected override void Dispose(bool disposing)
{
if (db != null)
{
db.Dispose();
}
base.Dispose(disposing);
}
public ActionResult Login()
{
var result = db.User.Select(x=>x);
// Do i need to call db.Dispose here? or will it get dispose automatically?
return View(result );
}
}
I'm using the object of mydbcontext db here to get user's list.
Do i need to call db.dispose explicitly or using statement inside my login action result or will it dispose the object of mydbcontext automatically.