Skip to content

SQL-294: PolicyOutputDocumentExtensions.SeedForDocumentTesting

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

Classification

Field Value
SQL ID SQL-294
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 SeedForDocumentTesting

Tables

Table Access Columns used
output_document_type_code SELECT ×656 (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
ENDORSE_CODE INSERT ×656 (hypothetical) CODE, CODE_DESCR, correspond_type_code, output_document_type_code

LINQ statement

Source: Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:81.

// Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:81
uow.GetRepository<EndorseCode>().Seed(uow.GetRepository<OutputDocumentTypeCode>());

// Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:850-1513
public static void Seed(this IRepository<EndorseCode> repo, IRepository<OutputDocumentTypeCode> outputDocumentTypeCodeRepo)
{
    // the code below was generated using this sql statement:
    // select 'repo.Add(new EndorseCode { Code = "'||code||'", Description = "'||code_descr||'", CorrespondTypeCode = "'||correspond_type_code||'", OutputDocumentType = outputDocumentTypeCodeRepo.Query().FirstOrDefault(odtc => odtc.Code == "'||output_document_type_code||'")});'
    // from endorse_code
    // order by code

    repo.Add(new EndorseCode { Code = "200", Description = "Anniversary Rating Date Endorsement", CorrespondTypeCode = "E", OutputDocumentType = outputDocumentTypeCodeRepo.Query().FirstOrDefault(odtc => odtc.Code == "200") });
    // ... 655 further Add/AddCode call(s) through line 1513 (elided)
}

Sample SQL

Test double — no runtime SQL. This statement executes against TestUnitOfWork/TestRepository<T> (in-memory, List<TEntity>-backed test doubles in SAIF.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 NHibernate IUnitOfWork using 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
-- per Add: outputDocumentTypeCodeRepo.Query().FirstOrDefault(odtc => odtc.Code == "<code>")
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.code = :p0  -- e.g. '200')
WHERE ROWNUM <= 1

INSERT INTO ENDORSE_CODE (
  CODE,
  CODE_DESCR,
  correspond_type_code,
  output_document_type_code)
VALUES (
  :Code,
  :Description,
  :CorrespondTypeCode,
  :OutputDocumentType)
-- issued 656 times (lines 856-1513)

Translation notes: - Each of the 657 Add calls embeds its own lookup, so the pair (SELECT + INSERT) repeats 657 times.

Sources

  • Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:81