Skip to content

SQL-298: Retrieve SpecialHandlingCode via SaveLegalBill

This statement retrieves a SpecialHandlingCode matching a legal bill's special-handling code via NHibernate LINQ, executed from Services/SAIF.Services/Legal/Bills/BillSaveService.cs (L336) and materialized with SingleOrDefault. It backs SaveLegalBill, which resolves the special handling code entity referenced by an incoming legal bill before persisting it.

Classification

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

Parameters

Parameter Direction Type Max length Description
:Code Input string N/A x.Code == bill.SpecialHandling.Code

Tables

Table Access Columns used
CL_PAYMENT_SPCL_HANDLING_CODE SELECT CODE, CODE_DESCR, UPDATE_DATE, UPDATE_USER, UPDATE_NUM

LINQ statement

Source: Services/SAIF.Services/Legal/Bills/BillSaveService.cs:334

// Services/SAIF.Services/Legal/Bills/BillSaveService.cs:334-337
legalBill.SpecialHandling = bill.SpecialHandling == null
        ? null
        : _unitOfWork.GetRepository<SpecialHandlingCode>()
                .Query().SingleOrDefault(x => x.Code == bill.SpecialHandling.Code);

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
  CPSHC.CODE,
  CPSHC.CODE_DESCR,
  CPSHC.UPDATE_DATE,
  CPSHC.UPDATE_USER,
  CPSHC.UPDATE_NUM
FROM CL_PAYMENT_SPCL_HANDLING_CODE CPSHC
WHERE CPSHC.CODE = :Code
-- NHibernate expects at most one row

Translation notes: - Runs only when bill.SpecialHandling != null (C# ternary). - Single/SingleOrDefault → no row limit; NHibernate throws if more than one row is returned.

Operations and processes

Sources

  • Services/SAIF.Services/Legal/Bills/BillSaveService.cs (L336)