SQL-313: Retrieve SubpoenaStatus via UpdateSubpoenaStatus¶
This statement retrieves the SUBPOENA_STATUS_CODE row for the "paid" status code via NHibernate LINQ over IUnitOfWork.GetRepository<SubpoenaStatus>(). It is executed by OpposingCounselService.UpdateSubpoenaStatus (Services/SAIF.Services/Legal/Subpoenas/OpposingCounselService.cs (L177)) so the subpoena's status can be reassigned to PAID.
Classification¶
| Field | Value |
|---|---|
| SQL ID | SQL-313 |
| Operation type | Read |
| Execution method | ORM (NHibernate LINQ) |
| Database | Oracle |
| Schema | [unqualified]** |
| Command type | N/A (ORM-generated) |
| Business object | OpposingCounselService |
| Criteria property | N/A — ORM |
| Lifecycle method | UpdateSubpoenaStatus |
Parameters¶
None (literals only or full-table read).
Tables¶
| Table | Access | Columns used |
|---|---|---|
| SUBPOENA_STATUS_CODE | SELECT | CODE, CODE_DESCR |
LINQ statement¶
Source: Services/SAIF.Services/Legal/Subpoenas/OpposingCounselService.cs:177
// Services/SAIF.Services/Legal/Subpoenas/OpposingCounselService.cs:177-179
subpoena.SubpoenaStatus = _unitOfWork.GetRepository<SubpoenaData.SubpoenaStatus>()
.Query()
.SingleOrDefault(x => x.Code == SubpoenaData.SubpoenaStatus.PaidCode);
Sample SQL¶
Inferred SQL: This SQL was inferred from the LINQ statement above and the NHibernate mappings. It is not concrete SQL from source code; NHibernate generates the executed statement at runtime, so aliases, column order, join syntax, and bind-parameter names may differ.
-- Inferred from LINQ (NHibernate mapping translation); not concrete SQL
SELECT
SSC.CODE,
SSC.CODE_DESCR
FROM SUBPOENA_STATUS_CODE SSC
WHERE SSC.CODE = 'PAID'
-- NHibernate expects at most one row
Translation notes:
- Constants from Data/SAIF.Data/Model/Legal/Subpoenas/SubpoenaStatus.cs: ApprovedCode = "APPR" (L6), ReadyToPayCode = "PAY" (L7), PaidCode = "PAID" (L8).
- Executes once per subpoena inside the foreach (L175); LINQ queries are not served from the first-level cache. The status assignment then causes an UPDATE SUBPOENA at flush — a separate write.
- Single/SingleOrDefault → no row limit; NHibernate throws if more than one row is returned.
Operations and processes¶
- OpposingCounselService.UpdateSubpoenaStatus — see Operations and processes
Sources¶
Services/SAIF.Services/Legal/Subpoenas/OpposingCounselService.cs (L177)