Skip to content

SQL-267: Retrieve Policy

This statement loads the single Policy matching a claim's policy number, used to attach the policy to a claim task when creating or updating tasks. It runs from TaskService.CreateTask, CreateTaskStateless, and UpdateTask via IUnitOfWork.GetRepository<T>(), executed from Services/SAIF.Services/Claims/Tasks/TaskService.cs (L510, L596, L685).

Classification

Field Value
SQL ID SQL-267
Operation type Read
Execution method ORM (NHibernate LINQ)
Database Oracle
Schema [unqualified]**
Command type N/A (ORM-generated)
Business object TaskService
Criteria property N/A — ORM
Lifecycle method CreateTask, CreateTaskStateless, UpdateTask

Parameters

Parameter Direction Type Max length Description
:PolicyNumber Input long N/A ...Claim.PolicyNumber — the policy number of the task's claim

Tables

Table Access Columns used
POLICY SELECT POLICY_NUM, POLICY_NAME, LEGAL_NAME, SECURE_POLICY_CODE, OFFICE_CODE, ACCOUNT_NUM, POLICY_STATUS_CODE, MARKET_TYPE_CODE, POLICY_RELATIONSHIP_POLICY_NUM, POLICY_RELATIONSHIP_CODE, customer_service_team_code, ENTITY_CODE, TRADING_SEQ_NUM, RATE_ACCOUNT, AGENT_NUM

LINQ statement

Source: Services/SAIF.Services/Claims/Tasks/TaskService.cs:510

// Services/SAIF.Services/Claims/Tasks/TaskService.cs:510-511
newTask.Policy = _unitOfWork.GetRepository<Policy>().Query()
    .SingleOrDefault(x => x.PolicyNumber == newTask.Claim.PolicyNumber);

// Services/SAIF.Services/Claims/Tasks/TaskService.cs:596-597
taskData.Policy = _unitOfWork.GetRepository<Policy>().Query()
    .SingleOrDefault(x => x.PolicyNumber == taskData.Claim.PolicyNumber);

// Services/SAIF.Services/Claims/Tasks/TaskService.cs:685-686
taskData.Policy = _unitOfWork.GetRepository<Policy>().Query()
    .SingleOrDefault(x => x.PolicyNumber == taskData.Claim.PolicyNumber);

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
  P.POLICY_NUM,
  P.POLICY_NAME,
  P.LEGAL_NAME,
  P.SECURE_POLICY_CODE,
  P.OFFICE_CODE,
  P.ACCOUNT_NUM,
  P.POLICY_STATUS_CODE,
  P.MARKET_TYPE_CODE,
  P.POLICY_RELATIONSHIP_POLICY_NUM,
  P.POLICY_RELATIONSHIP_CODE,
  P.customer_service_team_code,
  P.ENTITY_CODE,
  P.TRADING_SEQ_NUM,
  P.RATE_ACCOUNT,
  P.AGENT_NUM
FROM POLICY P
WHERE P.POLICY_NUM = :PolicyNumber
-- NHibernate expects at most one row

Translation notes: - Single/SingleOrDefault → no row limit; NHibernate throws if more than one row is returned. - Expressions that do not reference the lambda parameter (captured locals, members of already-loaded objects, Convert.ToInt64(...), DateTime.Today) are evaluated client-side by NHibernate's partial evaluator and bound as a single parameter value. - OFFICE_CODE is mapped both as Map(OfficeCode) (PolicyMap.cs:18) and References(Office) (PolicyMap.cs:26); it is selected once. All other References contribute their FK column only; HasMany collections (Periods, DbaNames, OscPolicies, SubmissionPolicies, TeamFunctions, BusinessAffiliates) are lazy and not selected.

Operations and processes

Business rules

Sources

  • Services/SAIF.Services/Claims/Tasks/TaskService.cs (L510, L596, L685)