I\'m learning EF now and have a question regarding the ObjectContext:
Should I create instance of ObjectContext for every query (function) when I access the database
public class DBModel {
private const string _PREFIX = "ObjectContext";
// DBModel.GetInstance();
public static ObjectContext GetInstance() {
var key = CreateKey();
HttpContext.Current.Items[key] = HttpContext.Current.Items[key] ?? Activator.CreateInstance();
return HttpContext.Current.Items[key] as ObjectContext;
}
private static string CreateKey() {
return string.Format("{0}_{1}", _PREFIX, typeof(T).Name);
}
}