Skip to content

SQL-295: Retrieve RtwLoadAssignment via GetRTWLoadCode

This statement retrieves the active RtwLoadAssignment for a given load user (an unexpired assignment) via NHibernate LINQ, executed from Services/SAIF.Services/Claims/RTW/RTWService.cs (L33) and materialized with SingleOrDefault. It backs GetRTWLoadCode, which resolves the RTW load code currently assigned to a user for return-to-work processing.

Classification

Field Value
SQL ID SQL-295
Operation type Read
Execution method ORM (NHibernate LINQ)
Database Oracle
Schema [unqualified]**
Command type N/A (ORM-generated)
Business object RTWService
Criteria property N/A — ORM
Lifecycle method GetRTWLoadCode

Parameters

Parameter Direction Type Max length Description
:loadUser Input string N/A Load user name, lower-cased (loadUser.ToLower(), after the optional TEST prefix strip)

Tables

Table Access Columns used
RTW_LOAD_ASSIGNMENT SELECT RTW_LOAD_ASSIGNMENT_SEQ_NUM, EFF_DATE, EXP_DATE, LOAD_USER, UPDATE_USER, UPDATE_DATE, UPDATE_NUM, RTW_LOAD_CODE

LINQ statement

Source: Services/SAIF.Services/Claims/RTW/RTWService.cs:33

// Services/SAIF.Services/Claims/RTW/RTWService.cs:33-35
var singleOrDefault = UnitOfWork.GetRepository<RtwLoadAssignment>().Query()
     .SingleOrDefault(x => x.LoadUser.ToLower() == loadUser.ToLower()
                   && x.ExpirationDate == null);

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
  RLA.RTW_LOAD_ASSIGNMENT_SEQ_NUM,
  RLA.EFF_DATE,
  RLA.EXP_DATE,
  RLA.LOAD_USER,
  RLA.UPDATE_USER,
  RLA.UPDATE_DATE,
  RLA.UPDATE_NUM,
  RLA.RTW_LOAD_CODE
FROM RTW_LOAD_ASSIGNMENT RLA
WHERE LOWER(RLA.LOAD_USER) = :loadUser
  AND RLA.EXP_DATE IS NULL
-- NHibernate expects at most one row

Translation notes: - x.LoadUser.ToLower() references the entity → LOWER(...); loadUser.ToLower() does not → bound value. - == null → IS NULL. - Single/SingleOrDefault → no row limit; NHibernate throws if more than one row is returned.

Operations and processes

Sources

  • Services/SAIF.Services/Claims/RTW/RTWService.cs (L33)