Skip to content

InvestigationRepositoryExtensions

InvestigationRepositoryExtensions is a static class of extension methods on IRepository<Investigation> that run raw, hand-written Oracle SQL (via CreateSqlQuery) instead of NHibernate mappings, because — per an inline code comment in the source — "using nhibernate named queries with mappings wasn't working" for this join. Both methods cast the IRepository<Investigation> receiver to the concrete Repository<Investigation> to reach its Session property, meaning they only work when the runtime type behind the interface is actually Repository<Investigation>.

Purpose

  • Resolve the display name of an investigation's subject (worker, company, or provider-location business name, with nvl fallbacks) and the associated worker id and policy name, per SDN-BR-050.
  • Resolve the claim id associated with an investigation case number.

Context

  • Namespace: SAIF.Data.NHibernate.Repositories.Investigations
  • Assembly/package: SAIF.Data.NHibernate (ships inside the SAIF.SAIFCode.Core NuGet package)
  • Static class; extension methods target IRepository<Investigation> (external interface, SAIF.Framework.Data.NHibernate) and internally cast to Repository<Investigation> (external, same library) to access Session.

Public members

Member Signature Purpose
GetSubjectName public static GetSubjectNameData GetSubjectName(this IRepository<Investigation> repo, long caseNumber) Casts repo to Repository<Investigation>, runs an inline SQL SELECT joining investigation, subject, person, company, provider_location, and policy for the given caseNumber, and resolves the worker/subject display name using nvl(person.NAME, nvl(company_name, nvl(business_name, ''))). Returns null if no row matches; otherwise returns a GetSubjectNameData with LegacyDataWorkerName, WorkerId (nullable, converted from decimal), and PolicyName (SDN-BR-050, SQL-032).
GetClaimId public static long GetClaimId(this IRepository<Investigation> repo, long caseNumber) Casts repo to Repository<Investigation>, runs an inline SQL SELECT inv.claim_id FROM investigation inv WHERE investigation_seq_num = :investigationId, and returns the claim id converted to long via Convert.ToInt64 (SQL-033).

Behavioral notes

  • Both methods bind their SQL parameter (:investigationId) explicitly via SetParameter<long>, so caller-supplied case numbers cannot be used for SQL injection (SC-SDN-05, Security and authorization).
  • GetSubjectName reads the raw ADO result as an untyped Array ((Array)result) and indexes into it positionally (GetValue(0), GetValue(1), GetValue(2)); any change to the column order in the inline SQL would silently break the mapping without a compile-time error*.
  • GetClaimId will throw an unhandled InvalidCastException/FormatException from Convert.ToInt64 if no investigation matches caseNumber (i.e. UniqueResult() returns null), since Convert.ToInt64(null) returns 0 rather than throwing — callers should verify this edge case before relying on a non-zero result as "found"*.

Constraints and usage notes

  • Both extension methods require the IRepository<Investigation> instance to actually be a Repository<Investigation> at runtime; passing any other IRepository<Investigation> implementation will throw an InvalidCastException*.

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.

Sources

  • Data/SAIF.Data.NHibernate/Repositories/Investigations/InvestigationRepositoryExtensions.cs