RepositoryBase<TEntity> is the abstract generic CRUD/query surface shared by every repository in this library. It wraps an ISessionStrategy (stateful or stateless, per BR-003) and translates repository calls into the corresponding NHibernate session operation, diverging in behavior depending on which strategy the owning NHibernateUnitOfWork was built with. It is classified as a framework-inherited type because it implements the external IRepository<TEntity> contract, which could not be located in this repository (see Dependencies).
Provides Add, Update, Delete, Query, Get, Load generically for any mapped entity type TEntity, delegating to the ISessionStrategy obtained from the constructing NHibernateUnitOfWork.
Exposes SystemDate, sourced from ISessionHelper.SystemDate, which runs an engine-specific "now" SQL query with a local-clock fallback (see BR-004).
Is the base class every repository, including the concrete Repository<TEntity>, derives from — implements the external IRepository<TEntity> contract.
Delegates to Session.Update(entity): under the stateful strategy this is a no-op (relies on NHibernate dirty-checking flushed at Commit()); under the stateless strategy this issues an explicit IStatelessSession.Update(entity) call. See BR-003.
Delete
public void Delete(TEntity entity)
Delegates to Session.Delete(entity) in both session strategies.
Query
public IQueryable<TEntity> Query()
Delegates to Session.Query<TEntity>() (LINQ to NHibernate) in both session strategies.
Stateful: ISession.Load<TEntity>(id) (lazy proxy). Stateless: also delegates to IStatelessSession.Get<TEntity>(id) — no distinct lazy-proxy path exists for the stateless strategy.
SystemDate
public DateTime SystemDate { get; }
Reads SessionHelper.SystemDate, which runs the engine-specific date SQL (select sysdate from dual for Oracle, Select GetDate() for SQL Server) and falls back to DateTime.Now if the result is null, DateTime.MinValue, or DateTime.MaxValue. See BR-004.
The divergence between stateful Update (no-op) and stateless Update (explicit write) is the single most consequential behavioral difference a caller must be aware of when switching between OracleUnitOfWorkFactory/SqlServerUnitOfWorkFactory (stateful) and OracleStatelessUnitOfWorkFactory (stateless) — see BR-003.
Load under the stateless strategy does not provide lazy-loading proxies, unlike the stateful strategy's ISession.Load — callers expecting a proxy object will instead get a fully materialized entity.
This class is abstract; it is never instantiated directly — Repository<TEntity> is the concrete subclass consumers use.
A RepositoryBase<TEntity> instance is permanently bound to the ISessionStrategy/session it was constructed with; it cannot be moved to a different unit of work (see BR-005).