When using ado.net, should I worry about opening and closing too many connections?
For example, say I have an MVC controller method that calls 3 separate repositories to fill all the needed objects.
public ActionResult()
{
var codesRepository = new CodesRepository();
viewModel.codes = codesRepository.GetCodesByName("D");
var employeeRepository = new EmployeeRepository();
viewModel.employees = employeeRepository.GetByName("Thomas");
var companyRepository = new CompanyRepository();
viewModel.company = companyRepository.GetById(20);
//.... rest of code
}
In each GetBy method above, I am opening and closing a connection.
using(var connection = DbFactory.GetConnection('SQLBase')
{
// code to fill the objects.
}
Do I need to worry about this approach being that I am opening and disposing a connection for each method called? It seems to me that the same connection should be used for all 3?
I've read about connection pooling a bit. Is that a database specific feature, or a feature in ado.net?