Skip to content

SQL-145: EdiQueryProvider.GetBillBySegmentCount

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

Classification

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

Parameters

Parameter Direction Type Max length Description
:billReport Input BillReport N/A Method argument; bound as its identifier
:segmentCount Input long N/A Method argument

Tables

Table Access Columns used
EDI_BILL SELECT EDI_BILL_SEQ_NUM, UPDATE_NUM, BILL_ID, CLAIM_ID, SAIF_CLAIM_NUM, POLICY_NUM, EDI_BILL_CLM_SEGMENT_ID, UPDATE_DATE, UPDATE_USER, EDI_BILL_REPORT_SEQ_NUM

LINQ statement

Source: Data/SAIF.Data/Queries/Edi/EdiQueryProvider.cs:33. The repository is obtained at Data/SAIF.Data/Queries/Edi/EdiQueryProvider.cs:16.

// Data/SAIF.Data/Queries/Edi/EdiQueryProvider.cs:16
_billRepository = Factory.GetRepository<Bill>().Query();

// Data/SAIF.Data/Queries/Edi/EdiQueryProvider.cs:33
return _billRepository.OrderByDescending(x => x.BillClaimSegmentId).FirstOrDefault(x => x.BillReport  == billReport && x.BillClaimSegmentId < segmentCount);

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
    EB.EDI_BILL_SEQ_NUM,
    EB.UPDATE_NUM,
    EB.BILL_ID,
    EB.CLAIM_ID,
    EB.SAIF_CLAIM_NUM,
    EB.POLICY_NUM,
    EB.EDI_BILL_CLM_SEGMENT_ID,
    EB.UPDATE_DATE,
    EB.UPDATE_USER,
    EB.EDI_BILL_REPORT_SEQ_NUM
  FROM EDI_BILL EB
  WHERE EB.EDI_BILL_REPORT_SEQ_NUM = :billReport
    AND EB.EDI_BILL_CLM_SEGMENT_ID < :segmentCount
  ORDER BY EB.EDI_BILL_CLM_SEGMENT_ID DESC
)
WHERE ROWNUM <= 1

Translation notes: - Oracle10 row limit for FirstOrDefault(): the query (including any ORDER BY) is wrapped in ROWNUM <= 1 (limit written inline; NHibernate binds it as a parameter at runtime). - The OrderByDescending comes before the predicate-bearing FirstOrDefault(pred). NHibernate folds the predicate into WHERE and keeps the ordering.

Operations and processes

Sources

  • Data/SAIF.Data/Queries/Edi/EdiQueryProvider.cs:33