---
title: DomainRepositoryBase<TItem>
summary: API reference for DomainRepositoryBase<TItem>.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Domain
reference_type: package
---

# DomainRepositoryBase\<TItem\>

`DomainRepositoryBase<TItem>` extends `DomainBase<TItem>` to add a `SAIF.Framework.Common` `IRepositoryFactory` collaborator, giving domain wrappers that need to persist or delete entities (rather than only query them) a standard way to receive that dependency. It is the counterpart to `DomainQueryBase<TItem,TQueryProvider>`: where the query-base family is built around a read-oriented query provider, this family is built around the repository factory that domain types such as note and audit wrappers use to call `GetRepository<T>().Add`/`Delete` against the persistence layer, per the repository-factory injection pattern used across SAIF.Domain.

## Purpose
- Adds repository-factory injection (`Factory`) to the base entity-wrapping contract from `DomainBase<TItem>`, so subclasses that create, update, or delete entities receive the `IRepositoryFactory` dependency uniformly through the constructor.
- Supplies constructor overloads that accept the repository factory alone, or the factory together with an already-known data entity, so subclasses can be constructed whether or not the entity exists yet.

## Context
- Namespace: `SAIF.Domain`
- Assembly/package: `SAIF.Domain` (`Domain/SAIF.Domain/SAIF.Domain.csproj`, .NET Framework 4.6.2 class library)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| DomainRepositoryBase (constructor) | `protected DomainRepositoryBase(IRepositoryFactory factory)` | Initializes the wrapper with the repository factory used for persistence operations, without an existing data entity. |
| DomainRepositoryBase (constructor) | `protected DomainRepositoryBase(IRepositoryFactory factory, TItem data) : base(data)` | Initializes the wrapper with both the repository factory and the backing data entity in one call. |
| DomainRepositoryBase (constructor) | `protected DomainRepositoryBase(TItem data) : base(data)` | Initializes the wrapper with a known data entity when no repository factory is needed at construction. |
| DomainRepositoryBase (parameterless constructor) | `internal DomainRepositoryBase()` | Internal-only constructor reserved for framework/test scaffolding*; not intended for library consumers to call directly. |
| Factory | `protected IRepositoryFactory Factory` | The injected repository factory that subclass methods use to obtain `IRepository<T>` instances and add or delete entities. |

## Inherited public members

Members in this section are inherited from `DomainBase<TItem>` in `SAIF.Domain`. They are available on this type through inheritance.

| Member | Signature | Purpose | Origin |
| --- | --- | --- | --- |
| HasData | `public virtual bool HasData { get; }` | Reports whether the wrapped entity is present, evaluated as `!DataItem.IsNull()` so callers can guard behaviour without null-reference risk. | `SAIF.Domain` — `DomainBase<TItem>` |
| DataItem | `protected TItem DataItem { get; set; }` | The backing NHibernate data entity that subclass methods read and mutate to implement domain behaviour. | `SAIF.Domain` — `DomainBase<TItem>` |

## Behavioral notes
- The parameterless `internal DomainRepositoryBase()` constructor bypasses both the entity and factory assignment; any subclass relying on it must set both `DataItem` and `Factory` itself before use**.

> **Note:** Statements marked with `*` were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with `**` could not be confirmed; treat as unknown until verified.

## Sources
- `Domain/SAIF.Domain/DomainRepositoryBase.cs`
- `Domain/SAIF.Domain/DomainBase.cs`
- `Domain/SAIF.Domain/SAIF.Domain.csproj`
