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


# PoliciesRepository

`PoliciesRepository` is a minimal `Repository<Policy>` specialization with a single operation: retrieving the WCIS standard premium for a policy period from Oracle. It delegates the actual computation to the Oracle function `PK72846_VIEW_POLICY.SP73111_GET_WCIS_STD_PREMIUM`, which is itself a thin wrapper that calls `pk73059_prem_hist_summary` to read the latest premium-history set for the policy period (`saif-data-nhibernate-db-analysis.md`).

## Purpose
- Provide the WCIS standard premium for a given policy number and effective date, sourced from the latest premium-history summary for that policy period (`PROC-RULE-040`, [Procedures](../../procedures/index.md)).

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

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| PoliciesRepository(NHibernateUnitOfWork) | `public PoliciesRepository(NHibernateUnitOfWork unitOfWork)` | Constructor; passes `unitOfWork` to the `Repository<Policy>` base. |
| GetPolicyStandardPremium | `public decimal GetPolicyStandardPremium(long policyNumber, DateTime effectiveDate)` | Evaluates `PK72846_VIEW_POLICY.SP73111_GET_WCIS_STD_PREMIUM(:in_policy_num, :in_pol_per_eff_date)` from `dual` via named query `Policies_GetPolicyStandardPremium` and returns the resulting decimal standard premium for the policy period ([SQL-035](../../sql/SQL-035-policies-repository-get-policy-standard-premium.md)). |

## Inherited public members

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

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

## Behavioral notes
- `GetPolicyStandardPremium` does not use the inherited `Repository<Policy>` CRUD surface; it is a single-value function evaluation via `UniqueResult<decimal>()` against `dual`*.
- The underlying Oracle function's own logic (which premium-history row it selects when multiple exist for the same period) is delegated to `pk73059_prem_hist_summary`, which was not retrieved by analysis (`saif-data-nhibernate-db-analysis.md`)**.

## Constraints and usage notes
- Callers must supply a valid `policyNumber`/`effectiveDate` pair that resolves to a premium-history row in Oracle; an unmatched pair's behavior (null vs. exception) was not verified**.

> **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/PoliciesRepository.cs`
