SAIF.Framework.Data.NHibernate overview¶
Documentation context: Packaged Component (NuGet)
SAIF.Framework.Data.NHibernate is a layered NHibernate ORM data-access library that implements and consumes — rather than defines — the unit-of-work/repository/session seam used by consuming applications, together with 42 FluentNHibernate entity mappings across 10 domain areas. The seam contracts — IUnitOfWork, IRepository<TEntity>, ISessionHelper, and IDataEntity — are supplied by the SAIF.Framework.Core package dependency (namespace SAIF.Data), not by the consuming application: this project's RootNamespace (SAIF.Data.NHibernate) nests under Core's SAIF.Data namespace, so C# enclosing-namespace lookup brings Core's types into scope without a using directive. This project's own SAIF.Data.NHibernate.Interfaces namespace is unrelated and holds only its 3 locally-declared interfaces (IConfigurationFactory, ISessionStrategy, IUnitOfWorkFactory).
Purpose¶
- Provides engine-specific (Oracle and SQL Server) configuration and unit-of-work factories that build and cache NHibernate
Configuration/ISessionFactoryinstances and hand out transaction-scoped units of work. - Provides a generic CRUD/query repository surface (
Add/Update/Delete/Query/Get/Load/SystemDate) usable against any entity mapped in the assembly, abstracting over stateful (ISession) and stateless (IStatelessSession) NHibernate session semantics behind a commonISessionStrategyseam. - Declaratively maps 42 entities from the
SAIF.Data.Model.*namespaces to their relational schema via FluentNHibernateClassMap<TEntity>classes, discovered by assembly scanning rather than direct external consumption. - Consumed by applications that need to wire up dependency injection against
IConfigurationFactory/IUnitOfWorkFactory/ISessionStrategyto obtain database access for the 42 mapped entities.
Responsibilities¶
- Build and cache engine-specific NHibernate configurations and session factories keyed by connection string.
- Own the unit-of-work transaction boundary (
Begin()/Commit()/Rollback()). - Provide generic repository CRUD/query operations over either session strategy.
- Supply engine-specific server-time retrieval with a local-clock fallback.
- Provide one domain-specific extension (
ImageRepositoryExtensions) for Oracle sequence-based ID generation in the Imaging domain.
Key components¶
IConfigurationFactory/ConfigurationFactoryBase/OracleConfigurationFactory/SqlServerConfigurationFactory: build and cache engine-specific NHibernateConfiguration/ISessionFactoryinstances.IUnitOfWorkFactory/UnitOfWorkFactoryBase/OracleUnitOfWorkFactory/OracleStatelessUnitOfWorkFactory/SqlServerUnitOfWorkFactory: constructNHibernateUnitOfWorkinstances per engine/session-strategy combination.NHibernateUnitOfWork: owns the transaction boundary and hands outRepository<TEntity>instances.Repository<TEntity>/RepositoryBase<TEntity>: generic CRUD + LINQ query surface overISessionStrategy.ImageRepositoryExtensions: Oracle sequence-based ID generation extension methods for the Imaging domain.Mappings/: 42ClassMap<TEntity>classes across 10 domain sub-folders (Contacts,Deployment,Employee,Imaging,Menu,PDF,Preferences,Printing,Users,WebContext).
Related documentation¶
- Index
- Architecture
- Dependencies
- Operations and processes
- Business rules
- Database tables
- SQL catalog
- API reference
Sources¶
SAIF.Framework.Data.NHibernate.csprojSAIF.Framework.Data.NHibernate.nuspec