SQL-288: PolicyOutputDocumentExtensions.SeedForDocumentTesting¶
This statement is a read operation invoked through ORM (NHibernate LINQ). Executed by PolicyOutputDocumentExtensions.SeedForDocumentTesting.
Classification¶
| Field | Value |
|---|---|
| SQL ID | SQL-288 |
| 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 |
|---|---|---|
| document_status_code | SELECT (existence) + INSERT, ×4 (hypothetical) | code, code_descr |
LINQ statement¶
Source: Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:74.
// Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:74
uow.GetRepository<DocumentStatusCode>().Seed();
// Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:91-97
public static void Seed(this IRepository<DocumentStatusCode> repo)
{
repo.AddCode(DocumentStatusCode.PendingDocumentStatusCode, "Pending");
repo.AddCode(DocumentStatusCode.HeldDocumentStatusCode, "Held");
repo.AddCode(DocumentStatusCode.DeletedDocumentStatusCode, "Deleted");
// ... 1 further Add/AddCode call(s) through line 97 (elided)
}
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
-- AddCode pattern (SharedExtensions.cs:26-27), issued 4 time(s); first call shown ('DocumentStatusCode.PendingDocumentStatusCode', 'Pending')
SELECT *
FROM (
SELECT 1
FROM document_status_code DSC
WHERE DSC.code = :code
AND DSC.code_descr = :description)
WHERE ROWNUM <= 1
-- only when the probe returns no row
INSERT INTO document_status_code (
code,
code_descr)
VALUES (
:Code,
:Description)
Translation notes:
- AddCode(code, description) (Data/SAIF.Data/TestRepository/RepositoryExtensions/SharedExtensions.cs:23-28) runs repo.Query().Any(x => x.Code == code && x.Description == description) and, only if false, repo.Add(new T { Code, Description }). The pair is issued once per call (4 calls, lines 91-97).
- Columns not set by AddCode are written as NULL (or the mapped default) in the INSERT.
- Codes are DocumentStatusCode.Pending/Held/Deleted/ReleasedDocumentStatusCode constants.
Sources¶
Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyOutputDocumentExtensions.cs:74