SQL-168: Retrieve DocumentTemplateOption via GetRequestLogXElement¶
This statement reads the DOCUMENT_TEMPLATE_OPTION rows for a specific document template, letting GetRequestLogXElement build the option list for a document request's XML representation.
Classification¶
| Field | Value |
|---|---|
| SQL ID | SQL-168 |
| Operation type | Read |
| Execution method | ORM (NHibernate LINQ) |
| Database | Oracle |
| Schema | [unqualified]** |
| Command type | N/A (ORM-generated) |
| Business object | DocumentTemplateOption |
| Criteria property | N/A — ORM |
| Lifecycle method | GetRequestLogXElement |
Parameters¶
| Parameter | Direction | Type | Max length | Description |
|---|---|---|---|---|
:templateId |
Input | long | N/A | = theRequest.MyDocTemplate.Id, captured → column DOCUMENT_TEMPLATE_SEQ_NUM |
Tables¶
| Table | Access | Columns used |
|---|---|---|
| DOCUMENT_TEMPLATE_OPTION | SELECT | all mapped columns; filter DOCUMENT_TEMPLATE_SEQ_NUM |
LINQ statement¶
Source: Services/SAIF.Services/Documents/DocumentRequestService.cs:144
var optionRecords = UnitOfWork.GetRepository<DocumentTemplateOption>().Query().Where(a => a.DocumentTemplateSeqNum == theRequest.MyDocTemplate.Id).ToList();
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 DTO.DOCUMENT_OPTION_SEQ_NUM,
DTO.DOCUMENT_TEMPLATE_SEQ_NUM,
DTO.CREATE_USER,
DTO.CREATE_DATE,
DTO.DOCUMENT_OPTION_CODE
FROM DOCUMENT_TEMPLATE_OPTION DTO
WHERE DTO.DOCUMENT_TEMPLATE_SEQ_NUM = :templateId;
Translation notes:
- theRequest.MyDocTemplate.Id is a captured value (client-side), evaluated before the query runs; DOCUMENT_TEMPLATE is not joined.
- option.DocumentOptionCode.Code read in the loop at L151 is the identifier of the reference, served from the FK column DOCUMENT_OPTION_CODE without loading the proxy — DOCUMENT_OPTION_CODE (the code table) is never joined.
- Mapping quirk: DocumentTemplateOptionMap declares .Column(" DOCUMENT_TEMPLATE_SEQ_NUM") with a leading space; shown trimmed here.
- Materialized by .ToList().
Operations and processes¶
- DocumentRequestService.GetRequestLogXElement — see Operations and processes
Sources¶
Services/SAIF.Services/Documents/DocumentRequestService.cs (L144)