Skip to content

SQL-183: OutputDocumentQueryProvider.GetDocumentDate

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

Classification

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

Tables

Table Access Columns used
batch_process_log SELECT module, control_text, run_date

LINQ statement

Source: Data/SAIF.Data/Queries/OutputDocuments/OutputDocumentQueryProvider.cs:41-43.

public DateTime GetDocumentDate()
{
    var entry = Factory.GetRepository<BatchProcessLog>().Query()
        .Where(x => x.Module == "DOCUMENTDATE")
        .OrderByDescending(x => x.RunDate).FirstOrDefault();

    return entry.IsNull()
        ? DateTime.Today
        : entry.RunDate;

}

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
    BPL.module,
    BPL.control_text,
    BPL.run_date
  FROM batch_process_log BPL
  WHERE BPL.module = 'DOCUMENTDATE'
  ORDER BY BPL.run_date DESC
) WHERE ROWNUM <= 1

Translation notes: - module is the entity Id (BatchProcessLogMap.cs:13), so at most one row can match and the ORDER BY/ROWNUM are effectively redundant. - When no row is found, the method returns DateTime.Today in memory.

Operations and processes

Business rules

Sources

  • Data/SAIF.Data/Queries/OutputDocuments/OutputDocumentQueryProvider.cs:41