SQL-298: PolicyOutputDocumentExtensions.GeneratePacket¶
This statement is a read operation invoked through ORM (NHibernate LINQ). Executed by PolicyOutputDocumentExtensions.GeneratePacket.
Classification¶
| Field | Value |
|---|---|
| SQL ID | SQL-298 |
| Operation type | Read |
| Execution method | ORM (NHibernate LINQ) |
| Database | Oracle* |
| Schema | [unqualified]** |
| Command type | N/A (ORM-generated) |
| Business object | PolicyOutputDocumentExtensions |
| Criteria property | N/A — ORM |
| Lifecycle method | GeneratePacket |
Parameters¶
| Parameter | Direction | Type | Max length | Description |
|---|---|---|---|---|
primaryType |
Input | string | N/A | Method argument of PolicyOutputDocumentExtensions.GeneratePacket bound into the ORM expression; NHibernate generates the bind variable at runtime |
secondaryType |
Input | string | N/A | Method argument of PolicyOutputDocumentExtensions.GeneratePacket bound into the ORM expression; NHibernate generates the bind variable at runtime |
packetCount |
Input | int | N/A | Method argument of PolicyOutputDocumentExtensions.GeneratePacket bound into the ORM expression; NHibernate generates the bind variable at runtime |
nonPacketDocCount |
Input | int | N/A | Method argument of PolicyOutputDocumentExtensions.GeneratePacket bound into the ORM expression; NHibernate generates the bind variable at runtime |
Tables¶
| Table | Access | Columns used |
|---|---|---|
| output_document_type_code | SELECT (hypothetical) | code, code_descr, agency_view_flag, agency_inbox_flag, manual_add_flag, freeform_flag, sort_priority_num, SOURCE_SYSTEM_CODE, PACKAGE_NAME, image_file_code, image_category_code, image_document_type_code, output_document_category_code, Direct_Write_Notify_Text_Code |
LINQ statement¶
Source: Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:1613.
// Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:1613-1614
var types = uow.GetRepository<OutputDocumentTypeCode>().Query()
.Where(x => x.IsAgencyViewable && x.Code != primaryType && x.Code != secondaryType).Take(packetCount);
// Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:1639-1641
var otypes = uow.GetRepository<OutputDocumentTypeCode>().Query()
.Where(x => x.IsAgencyViewable &&
!codes.Contains(x.Code)).Take(nonPacketDocCount);
Sample SQL¶
Test double — no runtime SQL. This statement executes against
TestUnitOfWork/TestRepository<T>(in-memory,List<TEntity>-backed test doubles inSAIF.Framework.Core); no NHibernate session is opened and no SQL is issued at runtime. The SQL below is the hypothetical statement the same expression would produce against a real NHibernateIUnitOfWorkusing the in-repo mappings, shown to document the mapping shape only — no database table is accessed when this code runs.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
-- (a) lines 1613-1614
SELECT *
FROM (
SELECT
ODTC.code,
ODTC.code_descr,
ODTC.agency_view_flag,
ODTC.agency_inbox_flag,
ODTC.manual_add_flag,
ODTC.freeform_flag,
ODTC.sort_priority_num,
ODTC.SOURCE_SYSTEM_CODE,
ODTC.PACKAGE_NAME,
ODTC.image_file_code,
ODTC.image_category_code,
ODTC.image_document_type_code,
ODTC.output_document_category_code,
ODTC.Direct_Write_Notify_Text_Code
FROM output_document_type_code ODTC
WHERE ODTC.agency_view_flag = 'Y'
AND ODTC.code <> :primaryType
AND ODTC.code <> :secondaryType)
WHERE ROWNUM <= :packetCount
-- (b) lines 1639-1641, only when nonPacketDocCount > 0
SELECT *
FROM (
SELECT
ODTC.code,
ODTC.code_descr,
ODTC.agency_view_flag,
ODTC.agency_inbox_flag,
ODTC.manual_add_flag,
ODTC.freeform_flag,
ODTC.sort_priority_num,
ODTC.SOURCE_SYSTEM_CODE,
ODTC.PACKAGE_NAME,
ODTC.image_file_code,
ODTC.image_category_code,
ODTC.image_document_type_code,
ODTC.output_document_category_code,
ODTC.Direct_Write_Notify_Text_Code
FROM output_document_type_code ODTC
WHERE ODTC.agency_view_flag = 'Y'
AND NOT (ODTC.code IN (:codes0, ...)))
WHERE ROWNUM <= :nonPacketDocCount
Translation notes:
- Not accessed: output_doc_image_type_xref (old page) — HasManyToMany(ImageDocumentTypes) join table, lazy and never navigated. image_document_type_code, output_document_category_code, output_doc_notify_text_code — FK columns only.
- types is a deferred IQueryable; (a) is executed twice — by ForEach (line 1625) and by Select(...).ToList() (line 1637).
- If primaryType/secondaryType is null, NHibernate renders x.Code != null as code IS NOT NULL (C# null semantics).
Sources¶
Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:1613