﻿---
title: "GroupRepository"
summary: API reference for GroupRepository
status: draft
owner: SAIF.Core documentation team
last_reviewed: 2026-09-24
library: SAIF.Data.NHibernate
reference_type: package
---


# GroupRepository

`GroupRepository` is a small `RepositoryBase<GroupAssociation>` implementation that resolves group ids to `GroupAssociation` entities (mapped to `group_association`) for the group-imaging subsystem; it has no filtering or write behavior of its own beyond the inherited generic CRUD surface.

## Purpose
- Look up a `GroupAssociation` by its group id, with an existence-check helper (`GroupFound`) and both throwing/non-throwing lookup variants (`GetGroup`/`GetGroupOrDefault`).

## Context
- Namespace: `SAIF.Data.NHibernate.Repositories.Groups`
- Assembly/package: `SAIF.Data.NHibernate` (ships inside the `SAIF.SAIFCode.Core` NuGet package)
- Base class: `RepositoryBase<GroupAssociation>` from `SAIF.Framework.Data.NHibernate` (external, resolved via Legends CLI — see Inherited public members below).
- Implements: `IGroupRepository`, defined in `SAIF.Data.Interfaces.Repositories.Groups`.

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| GroupRepository(NHibernateUnitOfWork) | `public GroupRepository(NHibernateUnitOfWork uow)` | Constructor; passes `uow` to the `RepositoryBase<GroupAssociation>` base. |
| GroupFound | `public bool GroupFound(string groupId)` | Returns `true` if a `GroupAssociation` with the given group id exists, by calling `GetGroupOrDefault` and checking for a non-null result ([SQL-026](../../sql/SQL-026-group-repository-group-found.md)). |
| GetGroupOrDefault | `public GroupAssociation GetGroupOrDefault(string groupId)` | Returns the single `GroupAssociation` matching `groupId` via `Query().SingleOrDefault()`, or `null` if none exists ([SQL-027](../../sql/SQL-027-group-repository-get-group-or-default.md)). |
| GetGroup | `public GroupAssociation GetGroup(string groupId)` | Returns the single `GroupAssociation` matching `groupId` via `Query().Single()`, throwing if none exists ([SQL-028](../../sql/SQL-028-group-repository-get-group.md)). |

## Inherited public members

Members in this section are inherited from `RepositoryBase<GroupAssociation>` in `SAIF.Framework.Data.NHibernate`. They are available on this type through inheritance.

| Member | Signature | Purpose | Origin |
| --- | --- | --- | --- |
| Add | `public void Add(GroupAssociation entity)` | Registers a new `GroupAssociation` entity for insertion on the next unit-of-work commit.† | `SAIF.Framework.Data.NHibernate` — `RepositoryBase<GroupAssociation>` |
| Update | `public void Update(GroupAssociation entity)` | Marks an existing `GroupAssociation` entity as modified for the next unit-of-work commit.† | `SAIF.Framework.Data.NHibernate` — `RepositoryBase<GroupAssociation>` |
| Delete | `public void Delete(GroupAssociation entity)` | Registers a `GroupAssociation` entity for deletion on the next unit-of-work commit.† | `SAIF.Framework.Data.NHibernate` — `RepositoryBase<GroupAssociation>` |
| Query | `public IQueryable<GroupAssociation> Query()` | Returns a LINQ-queryable session projection over `GroupAssociation`, used directly by `GetGroup`/`GetGroupOrDefault` above.† | `SAIF.Framework.Data.NHibernate` — `RepositoryBase<GroupAssociation>` |
| Get | `public GroupAssociation Get(object id)` | Loads a `GroupAssociation` by primary key, returning `null` if not found.† | `SAIF.Framework.Data.NHibernate` — `RepositoryBase<GroupAssociation>` |
| Load | `public GroupAssociation Load(object id)` | Loads a `GroupAssociation` by primary key as a (possibly proxied) reference, throwing if not found.† | `SAIF.Framework.Data.NHibernate` — `RepositoryBase<GroupAssociation>` |
| SystemDate | `public DateTime SystemDate { get; }` | Current system date/time as tracked by the underlying session/unit of work.† | `SAIF.Framework.Data.NHibernate` — `RepositoryBase<GroupAssociation>` |

## Behavioral notes
- All three of this type's own members are thin wrappers over the inherited `Query()` LINQ surface; there is no custom filtering, eager-loading, or write logic*.

## Constraints and usage notes
- `GetGroup` throws (`Single()`) if no `GroupAssociation` matches the supplied `groupId`; use `GetGroupOrDefault` or `GroupFound` first when existence is not guaranteed.

> **Note:** Statements marked with `†` are derived from dependency library
> documentation via the Legends CLI. Statements marked with `*` were inferred
> from code structure or contextual evidence. Statements marked with `**` could
> not be confirmed; treat as unknown until verified.

## Related documentation
- [Index](../../index.md)
- [Overview](../../overview.md)
- [Architecture](../../architecture.md)
- [Dependencies](../../dependencies.md)
- [Operations and processes](../../operations-processes.md)
- [Business rules](../../business-rules.md)
- [Database tables](../../database-tables.md)
- [SQL catalog](../../sql/index.md)
- [Procedures](../../procedures/index.md)
- [Security and authorization](../../security-authorization.md)
- [API reference](../index.md)

## Sources
- `Data/SAIF.Data.NHibernate/Repositories/Groups/GroupRepository.cs`
