/// <summary> /// Gets the ObjectContextManager object for the /// specified database. /// </summary> /// <param name="connectionString"> /// A database connection string. /// </param> /// <param name="label">Label for this context.</param> public static IObjectContextManager GetManager(string connectionString, string label) { lock (_lock) { var contextLabel = GetContextName(connectionString, label); ObjectContextManager mgr = null; if (ApplicationContext.LocalContext.Contains(contextLabel)) { mgr = (ObjectContextManager)(ApplicationContext.LocalContext[contextLabel]); } else { mgr = new ObjectContextManager(connectionString, label); ApplicationContext.LocalContext[contextLabel] = mgr; } mgr.AddRef(); return((IObjectContextManager)mgr); } }
/// <summary> /// Gets the ObjectContextManager object for the /// specified database. /// </summary> /// <param name="connectionString"> /// A database connection string. /// </param> /// <param name="label">Label for this context.</param> public static IObjectContextManager GetManager(string connectionString, string label) { lock (_lock) { var contextLabel = GetContextName(connectionString, label); ObjectContextManager mgr = null; if (ApplicationContext.LocalContext.Contains(contextLabel)) { mgr = (ObjectContextManager)(ApplicationContext.LocalContext[contextLabel]); } else { mgr = new ObjectContextManager(connectionString, label); ApplicationContext.LocalContext[contextLabel] = mgr; } mgr.AddRef(); return (IObjectContextManager)mgr; } }
public EntityFrameworkObjectContext(IPersistenceDetails persistenceDetails) { ContextManager = ObjectContextManager.GetManager(persistenceDetails.Location); }