IUnitOfWorkFactory¶
IUnitOfWorkFactory is the seam contract consuming applications depend on to obtain a NHibernateUnitOfWork for a connection string, without needing to know which database engine or session strategy (stateful/stateless) the concrete factory (OracleUnitOfWorkFactory, OracleStatelessUnitOfWorkFactory, SqlServerUnitOfWorkFactory) uses.
Purpose¶
- Defines the single operation (
GetUnitOfWork) consumers call to obtain a transaction-scoped unit of work bound to a freshly opened NHibernate session. - Allows application code to depend on this interface for dependency injection rather than a concrete engine-specific factory class.
Context¶
- Namespace:
SAIF.Data.NHibernate - Assembly/package:
SAIF.Framework.Data.NHibernate
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| GetUnitOfWork | NHibernateUnitOfWork GetUnitOfWork(string connectionString, int batchSize, bool showSql) |
Resolves (or builds and caches) an ISessionFactory for connectionString, opens a session appropriate to the implementation's engine/session-strategy combination, and returns a NHibernateUnitOfWork wrapping it. |
Behavioral notes¶
- Every call returns a new
NHibernateUnitOfWorkbound to a freshly opened session — theISessionFactoryis cached and reused, but the session/unit-of-work is not (see BR-005).
Constraints and usage notes¶
- Implementers must be constructed with a matching
IConfigurationFactoryso the session factory targets the correct database engine.
Sources¶
Interfaces/IUnitOfWorkFactory.csFactories/UnitOfWorkFactoryBase.cs