SQL-176: MedicareQueryProvider.GetNextMinumumSubmissionBatch¶
This statement is a read operation invoked through ORM (NHibernate LINQ). Executed by MedicareQueryProvider.GetNextMinumumSubmissionBatch.
Classification¶
| Field | Value |
|---|---|
| SQL ID | SQL-176 |
| Operation type | Read |
| Execution method | ORM (NHibernate LINQ) |
| Database | Oracle* |
| Schema | [unqualified]** |
| Command type | N/A (ORM-generated) |
| Business object | MedicareQueryProvider |
| Criteria property | N/A — ORM |
| Lifecycle method | GetNextMinumumSubmissionBatch |
Tables¶
| Table | Access | Columns used |
|---|---|---|
| MEDICARE_BENEFICIARY_QUERY_BAT | SELECT (outer + correlated-free subquery) | SUBMISSION_DATE, UPDATE_NUM, RESPONSE_DATE, SUBMITTED_WORKER_COUNT, MATCHED_WORKER_COUNT, UPDATE_USER, UPDATE_DATE |
LINQ statement¶
Source: Data/SAIF.Data/Queries/Claims/MedicareQueryProvider.cs:24-25. The repository/queryable is initialised at Data/SAIF.Data/Queries/Claims/MedicareQueryProvider.cs:17.
// Data/SAIF.Data/Queries/Claims/MedicareQueryProvider.cs:17
medicareBatchRepository = factory.GetRepository<MedicareBeneficiaryQueryBatch>().Query();
// Data/SAIF.Data/Queries/Claims/MedicareQueryProvider.cs:24-25
public MedicareBeneficiaryQueryBatch GetNextMinumumSubmissionBatch()
{
var medicarehold = medicareBatchRepository.Where(s => s.ResponseDate != null);
return medicareBatchRepository.SingleOrDefault(x => x.SubmissionDate == medicarehold.Min(d => d.SubmissionDate));
}
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
MBQB.SUBMISSION_DATE,
MBQB.UPDATE_NUM,
MBQB.RESPONSE_DATE,
MBQB.SUBMITTED_WORKER_COUNT,
MBQB.MATCHED_WORKER_COUNT,
MBQB.UPDATE_USER,
MBQB.UPDATE_DATE
FROM MEDICARE_BENEFICIARY_QUERY_BAT MBQB
WHERE MBQB.SUBMISSION_DATE = (
SELECT MIN(MBQB2.SUBMISSION_DATE)
FROM MEDICARE_BENEFICIARY_QUERY_BAT MBQB2
WHERE MBQB2.RESPONSE_DATE IS NOT NULL
)
-- SingleOrDefault: NHibernate expects at most one row
Translation notes:
- medicarehold is an un-materialized IQueryable. Using medicarehold.Min(m => m.BatchNumber) inside the outer lambda makes NHibernate emit it as a scalar subquery; it is not a separate round trip.
- SubmissionDate is the entity Id (Id(x => x.SubmissionDate).Column("SUBMISSION_DATE")).
Operations and processes¶
Business rules¶
Sources¶
Data/SAIF.Data/Queries/Claims/MedicareQueryProvider.cs:24