public IsRepository GetRepository() { var context = DependencyContainer.Get <EntityFrameworkRepository>(Id.ToString()); if (context == null) { context = new EntityFrameworkRepository(new T()); DependencyContainer.Set(Id.ToString(), context); } return(context); }
public static IsRepository ForceNew() { lock (Contexts) { var existingKey = CallContext.LogicalGetData("DatabaseContext") as string; if (!string.IsNullOrEmpty(existingKey)) { Dispose(Contexts[existingKey]); } var context = new EntityFrameworkRepository(new DatabaseContext()); var key = context.Id.ToString(); CallContext.LogicalSetData("DatabaseContext", key); Contexts.Add(key, context); return(context); } }