Skip to content

SQL-152: Retrieve DeptRevenueSoilAdjustment

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

Classification

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

Parameters

Parameter Direction Type Max length Description
runDate Input ** N/A x.CreateDate == runDate → column **

Tables

Table Access Columns used
DEPT_REVENUE_SOIL_ADJUSTMENT SELECT TRANS_CODE, CREATE_DATE, DEBTOR_SSN, UPDATE_NUM, REFERENCE_TEXT, PRIOR_BALANCE_AMT, CHANGE_AMT, LAST_NAME, FIRST_NAME, MIDDLE_INITIAL, SUFFIX, UPDATE_USER, UPDATE_DATE

LINQ statement

Source: Services/SAIF.Services/Collections/SoilService.cs:142

// Services/SAIF.Services/Collections/SoilService.cs:142-148
            var data = UnitOfWork.GetRepository<DataModel.DeptRevenueSoilAdjustment>()
                .Query().Where(x => x.CreateDate == runDate).GroupBy(x => x.TransCode)
                .Select(g => new
                {
                    g.Key,
                    myCount = g.Count()
                }).ToList();

// Services/SAIF.Services/Collections/SoilService.cs:183-184
            var data = UnitOfWork.GetRepository<DataModel.DeptRevenueSoilAdjustment>()
                .Query().Where(x => x.CreateDate == runDate).OrderBy(x => x.DebtorSsn);

// Services/SAIF.Services/Collections/SoilService.cs:186
            foreach (var row in data)

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/SoilService.cs:142
SELECT
  DRSA.TRANS_CODE AS Key,
  COUNT(*) AS myCount
FROM DEPT_REVENUE_SOIL_ADJUSTMENT DRSA
WHERE DRSA.CREATE_DATE = :runDate
GROUP BY DRSA.TRANS_CODE

-- Services/SAIF.Services/Collections/SoilService.cs:183
SELECT
  DRSA.CREATE_DATE,
  DRSA.DEBTOR_SSN,
  DRSA.UPDATE_NUM,
  DRSA.TRANS_CODE,
  DRSA.REFERENCE_TEXT,
  DRSA.PRIOR_BALANCE_AMT,
  DRSA.CHANGE_AMT,
  DRSA.LAST_NAME,
  DRSA.FIRST_NAME,
  DRSA.MIDDLE_INITIAL,
  DRSA.SUFFIX,
  DRSA.UPDATE_USER,
  DRSA.UPDATE_DATE
FROM DEPT_REVENUE_SOIL_ADJUSTMENT DRSA
WHERE DRSA.CREATE_DATE = :runDate
ORDER BY DRSA.DEBTOR_SSN

Translation notes: - L142-148: GroupBy(x => x.TransCode).Select(g => new { g.Key, myCount = g.Count() }) -> projection with GROUP BY; the switch over results (L151) runs in memory. - L183-184 is enumerated by foreach (L186). - CREATE_DATE is part of the composite key and is selected once.

Operations and processes

Sources

  • Services/SAIF.Services/Collections/SoilService.cs (L142, L183)