Skip to content

SQL-174: LocationQueryProvider.GetOfficeCode

This statement is a read operation invoked through ORM (NHibernate LINQ). Executed by LocationQueryProvider.GetOfficeCode.

Classification

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

Parameters

Parameter Direction Type Max length Description
code Input string N/A Method argument of LocationQueryProvider.GetOfficeCode bound into the ORM expression; NHibernate generates the bind variable at runtime

Tables

Table Access Columns used
OFFICE_CODE SELECT CODE, CODE_DESCR, CANCELLATION_TRACK_CODE, LOC_SEQ_NUM, PMS_OFFICE_CODE, POLICY_REGION_CODE, POLICY_RENEWAL_TRACK_CODE

LINQ statement

Source: Data/SAIF.Data/Queries/Locations/LocationQueryProvider.cs:85.

public OfficeCode GetOfficeCode(string code)
{
    return Factory.GetRepository<OfficeCode>().Query().FirstOrDefault(x => x.Code.ToLower() == code.ToLower());
}

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 * FROM (
  SELECT
    OC.CODE,
    OC.CODE_DESCR,
    OC.CANCELLATION_TRACK_CODE,
    OC.LOC_SEQ_NUM,
    OC.PMS_OFFICE_CODE,
    OC.POLICY_REGION_CODE,
    OC.POLICY_RENEWAL_TRACK_CODE
  FROM OFFICE_CODE OC
  WHERE LOWER(OC.CODE) = LOWER(:code)
) WHERE ROWNUM <= 1

Translation notes: - code.ToLower() has no lambda parameter, so it may be evaluated client-side (bound pre-lowered) instead of emitted as LOWER(:code). The result is the same either way. - Applying LOWER() to the column prevents use of a plain index on OFFICE_CODE.CODE.

Operations and processes

Business rules

Sources

  • Data/SAIF.Data/Queries/Locations/LocationQueryProvider.cs:85