protected virtual AbstractSchemaRepository CreateSchemaRepository(bool isReadOnly) { ISession session; var transaction = NhDependencyHelper.FactoryHelper.GenerateSessionAndTransaction(isReadOnly, out session); //TODO: When we support schema revisions, we'll have to pass the existing transaction into the GetRepository method just // like we do in the EntityRepositoryFactory return(new SchemaRepository(ProviderMetadata, RevisionRepositoryFactory.GetRepository(), transaction, session, FrameworkContext, isReadOnly)); }
protected virtual AbstractEntityRepository CreateEntityRepository(bool isReadOnly) { if (NhDependencyHelper == null) { var extra = "(null)"; if (DependencyHelper != null) { extra = DependencyHelper.GetType().Name; if (DependencyHelper.ProviderMetadata != null) { extra += " with key " + DependencyHelper.ProviderMetadata.Alias.IfNullOrWhiteSpace("(no key)"); } } throw new NullReferenceException("NhDependencyHelper is null and DependencyHelper is " + extra); } if (NhDependencyHelper.FactoryHelper == null) { throw new NullReferenceException("NhDependencyHelper.FactoryHelper is null"); } ISession session; var transaction = NhDependencyHelper.FactoryHelper.GenerateSessionAndTransaction(isReadOnly, out session); var schemaRepository = NhSchemaRepositoryFactory != null ? NhSchemaRepositoryFactory.GetRepository(transaction, isReadOnly) : SchemaRepositoryFactory.GetRepository(); var revisionRepository = NhRevisionRepositoryFactory != null ? NhRevisionRepositoryFactory.GetRepository(transaction, isReadOnly) : RevisionRepositoryFactory.GetRepository(); return(new EntityRepository(ProviderMetadata, schemaRepository, revisionRepository, transaction, session, FrameworkContext, isReadOnly)); }
/// <summary> /// Handles the disposal of resources. Derived from abstract class <see cref="DisposableObject"/> which handles common required locking logic. /// </summary> protected override void DisposeResources() { RevisionRepositoryFactory.Dispose(); SchemaRepositoryFactory.Dispose(); DependencyHelper.Dispose(); }
/// <summary> /// Get the repository with an existing transaction /// </summary> /// <param name="transaction"></param> /// <param name="isReadonly"> </param> /// <returns></returns> public AbstractSchemaRepository GetRepository(NhProviderTransaction transaction, bool isReadonly) { var session = NhDependencyHelper.FactoryHelper.GetSessionFromTransaction(transaction, isReadonly); return(new SchemaRepository(ProviderMetadata, RevisionRepositoryFactory.GetRepository(), transaction, session, FrameworkContext, isReadonly)); }