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
nvlfallbacks) 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 theSAIF.SAIFCode.CoreNuGet package) - Static class; extension methods target
IRepository<Investigation>(external interface,SAIF.Framework.Data.NHibernate) and internally cast toRepository<Investigation>(external, same library) to accessSession.
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 viaSetParameter<long>, so caller-supplied case numbers cannot be used for SQL injection (SC-SDN-05, Security and authorization). GetSubjectNamereads the raw ADO result as an untypedArray((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*.GetClaimIdwill throw an unhandledInvalidCastException/FormatExceptionfromConvert.ToInt64if no investigation matchescaseNumber(i.e.UniqueResult()returnsnull), sinceConvert.ToInt64(null)returns0rather 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 aRepository<Investigation>at runtime; passing any otherIRepository<Investigation>implementation will throw anInvalidCastException*.
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
- Overview
- Architecture
- Dependencies
- Operations and processes
- Business rules
- Database tables
- SQL catalog
- Procedures
- Security and authorization
- API reference
Sources¶
Data/SAIF.Data.NHibernate/Repositories/Investigations/InvestigationRepositoryExtensions.cs