Sep 3, 2010 at 4:36 PM
Edited Sep 3, 2010 at 4:37 PM
Im wondering if anyone could tell me if we should close / dispose the ObjectContext after usage or not?
What is best practices here, i was under the impression that we should close an object context as soon as we have used it.
When i look in NerdDinner.Models.DinnerRepository class they create the EF context as soon as an instance of the repository classs are instantitated.
public class DinnerRepository : NerdDinner.Models.IDinnerRepository
NerdDinnerEntities db = new NerdDinnerEntities();
But, i never see that this ObjectContext are closed explictly like if you had used:
using (NerdDinnerEntities db = new NerdDinnerEntities())
return db.Dinners.Where(d => d.Title.Contains(q)
So what is best practices here? Isnt it important to close this ObjectContext so
resources are released as fast as possible?