SQL-170: Retrieve DocumentTemplateOutputProfile¶
GetRequestLogXElement reads the DOCUMENT_TEMPLATE_OP rows for a document template's output profiles. IsWordDocument builds a second, differently-filtered query object but never enumerates it — the query is checked only with IQueryable.IsNull(), which is always false, so IsWordDocument always returns true and issues no SQL at all.
Classification¶
| Field | Value |
|---|---|
| SQL ID | SQL-170 |
| Operation type | Read |
| Execution method | ORM (NHibernate LINQ) |
| Database | Oracle |
| Schema | [unqualified]** |
| Command type | N/A (ORM-generated) |
| Business object | DocumentTemplateOutputProfile |
| Criteria property | N/A — ORM |
| Lifecycle method | GetRequestLogXElement, IsWordDocument |
Parameters¶
| Parameter | Direction | Type | Max length | Description |
|---|---|---|---|---|
:templateId |
Input | long | N/A | = theRequest.MyDocTemplate.Id, captured → column DOCUMENT_TEMPLATE_SEQ_NUM (statement 1, executed) |
Tables¶
| Table | Access | Columns used |
|---|---|---|
| DOCUMENT_TEMPLATE_OP | SELECT | all mapped columns; filter DOCUMENT_TEMPLATE_SEQ_NUM (statement 1, executed) |
LINQ statement¶
Source: Services/SAIF.Services/Documents/DocumentRequestService.cs:159. Second fragment (never enumerated — see below) at Services/SAIF.Services/Documents/DocumentRequestService.cs:242.
// Services/SAIF.Services/Documents/DocumentRequestService.cs:159
var outputProfiles = UnitOfWork.GetRepository<DocumentTemplateOutputProfile>().Query().Where(a => a.DocumentTemplateSeqNum == theRequest.MyDocTemplate.Id).ToList();
// Services/SAIF.Services/Documents/DocumentRequestService.cs:242
var result = UnitOfWork.GetRepository<DocumentTemplateOutputProfile>().Query().Where(a => a.DocumentTemplateSeqNum == docId && a.DocumentOutputProfileCode.Code == "WORD");
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
-- (1) L159 — GetRequestLogXElement (executed)
SELECT DTOP.DOCUMENT_TEMPLATE_OP_SEQ_NUM,
DTOP.DOCUMENT_TEMPLATE_SEQ_NUM,
DTOP.CREATE_USER,
DTOP.CREATE_DATE,
DTOP.DOCUMENT_OP_CODE
FROM DOCUMENT_TEMPLATE_OP DTOP
WHERE DTOP.DOCUMENT_TEMPLATE_SEQ_NUM = :templateId;
Dead code finding — statement (2), L242 (IsWordDocument): the IQueryable built at L242 is never enumerated. IsWordDocument only calls result.IsNull() at L243, which is a null check on the query object — that object is never null, so the check always evaluates false, IsWordDocument always returns true, and no query — inferred or otherwise — is ever sent to the database for this branch. No SQL block is shown for it because none executes. Had it been enumerated, it would filter on DOCUMENT_TEMPLATE_SEQ_NUM = :docId AND DOCUMENT_OP_CODE = 'WORD' (a.DocumentOutputProfileCode.Code is the reference identifier, so it resolves to the FK column with no join to DOCUMENT_OP_CODE).
Translation notes:
- Mapping quirk: leading space in .Column(" DOCUMENT_TEMPLATE_SEQ_NUM") (trimmed here).
- a.DocumentOutputProfileCode.Code (statement 2, if it were reachable) is the reference identifier → FK column DOCUMENT_TEMPLATE_OP.DOCUMENT_OP_CODE; DOCUMENT_OP_CODE is never joined.
Operations and processes¶
- DocumentRequestService.GetRequestLogXElement — see Operations and processes
- DocumentRequestService.IsWordDocument — see Operations and processes
Sources¶
Services/SAIF.Services/Documents/DocumentRequestService.cs (L159, L242)