Skip to content

SQL-106: Retrieve Case

This ORM statement performs a read operation on Case via IUnitOfWork.GetRepository<T>(), executed from Services/SAIF.Services/Collections/CalculateInterestService.cs (L76, L142).

Classification

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

Parameters

Parameter Direction Type Max length Description
caseInterest.CaseId Input ** N/A x.Id == caseInterest.CaseId → column LEGAL_COLLECTION_SEQ_NUM

Tables

Table Access Columns used
LEGAL_COLLECTION SELECT LEGAL_COLLECTION_SEQ_NUM, UPDATE_NUM, POLICY_NUM, SAIF_CLAIM_NUM, RECEIVED_DATE, RECORDING_COUNTY_CODE, STATE, COURT_CASE_NUM, CURRENT_BALANCE_AMT, UPDATE_USER, UPDATE_DATE, CREDIT_REP_USER, INTEREST_CALC_OPTION_CODE, INTEREST_ANNUAL_RATE, JUDGMENT_CODE, JUDGMENT_YEARS, LEGAL_COLLECTION_CODE, LEGAL_COLLECTION_STATUS_CODE

LINQ statement

Source: Services/SAIF.Services/Collections/CalculateInterestService.cs:76

// Services/SAIF.Services/Collections/CalculateInterestService.cs:76-78
                caseInterest.Case = _unitOfWork.GetRepository<DataModel.Case>()
                   .Query()
                   .SingleOrDefault(x => x.Id == caseInterest.CaseId);

// Services/SAIF.Services/Collections/CalculateInterestService.cs:142-144
                Case = _unitOfWork.GetRepository<DataModel.Case>()
                   .Query()
                   .SingleOrDefault(x => x.Id == caseInterest.CaseId)

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
-- Services/SAIF.Services/Collections/CalculateInterestService.cs:76
SELECT
  LC.LEGAL_COLLECTION_SEQ_NUM,
  LC.UPDATE_NUM,
  LC.POLICY_NUM,
  LC.SAIF_CLAIM_NUM,
  LC.RECEIVED_DATE,
  LC.RECORDING_COUNTY_CODE,
  LC.STATE,
  LC.COURT_CASE_NUM,
  LC.CURRENT_BALANCE_AMT,
  LC.UPDATE_USER,
  LC.UPDATE_DATE,
  LC.CREDIT_REP_USER,
  LC.INTEREST_CALC_OPTION_CODE,
  LC.INTEREST_ANNUAL_RATE,
  LC.JUDGMENT_CODE,
  LC.JUDGMENT_YEARS,
  LC.LEGAL_COLLECTION_CODE,
  LC.LEGAL_COLLECTION_STATUS_CODE
FROM LEGAL_COLLECTION LC
WHERE LC.LEGAL_COLLECTION_SEQ_NUM = :CaseId
-- NHibernate expects at most one row

-- Services/SAIF.Services/Collections/CalculateInterestService.cs:142
SELECT
  LC.LEGAL_COLLECTION_SEQ_NUM,
  LC.UPDATE_NUM,
  LC.POLICY_NUM,
  LC.SAIF_CLAIM_NUM,
  LC.RECEIVED_DATE,
  LC.RECORDING_COUNTY_CODE,
  LC.STATE,
  LC.COURT_CASE_NUM,
  LC.CURRENT_BALANCE_AMT,
  LC.UPDATE_USER,
  LC.UPDATE_DATE,
  LC.CREDIT_REP_USER,
  LC.INTEREST_CALC_OPTION_CODE,
  LC.INTEREST_ANNUAL_RATE,
  LC.JUDGMENT_CODE,
  LC.JUDGMENT_YEARS,
  LC.LEGAL_COLLECTION_CODE,
  LC.LEGAL_COLLECTION_STATUS_CODE
FROM LEGAL_COLLECTION LC
WHERE LC.LEGAL_COLLECTION_SEQ_NUM = :CaseId
-- NHibernate expects at most one row

Translation notes: - caseInterest.CaseId -> bind :CaseId. - Case has HasMany Activities/Debtors/Transactions with cascade (CaseMap.cs); collections load lazily with their own statements and are not part of this SELECT. References (CREDIT_REP_USER, INTEREST_CALC_OPTION_CODE, INTEREST_ANNUAL_RATE, JUDGMENT_CODE, JUDGMENT_YEARS, LEGAL_COLLECTION_CODE, LEGAL_COLLECTION_STATUS_CODE) contribute FK columns only; none of the referenced tables is joined.

Operations and processes

Sources

  • Services/SAIF.Services/Collections/CalculateInterestService.cs (L76, L142)