I'm starting with the Entity Framework and the repository pattern. I'm confused about the ObjectContext. Is it better to instantiate it each time we need it? I'm using like that:
private GenericRepository _genericRepository;
public EmployeeDAO()
{
var _context = new NorthwindEntities();
this._genericRepository = new GenericRepository(_context);
}
public Employee FindByID(int employeeID)
{
Employee _employee = this._genericRepository.Single<Employee>(x => x.EmployeeID == employeeID );
return _employee;
}