Skip to content

SQL-266: EbillingExtensions.SeedForEbilling

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

Classification

Field Value
SQL ID SQL-266
Operation type Read
Execution method ORM (NHibernate LINQ)
Database Oracle*
Schema [unqualified]**
Command type N/A (ORM-generated)
Business object EbillingExtensions
Criteria property N/A — ORM
Lifecycle method SeedForEbilling

Tables

Table Access Columns used
EBILL_BATCH_STATUS_CODE SELECT (existence) + INSERT, ×10 (hypothetical) CODE, UPDATE_NUM, CODE_DESCR, UPDATE_USER, UPDATE_DATE

LINQ statement

Source: Data/SAIF.Data/TestRepository/RepositoryExtensions/EbillingExtensions.cs:14.

// Data/SAIF.Data/TestRepository/RepositoryExtensions/EbillingExtensions.cs:14
uow.GetRepository<EbillBatchStatusCode>().Seed();

// Data/SAIF.Data/TestRepository/RepositoryExtensions/EbillingExtensions.cs:24-36
public static void Seed(this IRepository<EbillBatchStatusCode> repository)
{
    repository.AddCode("NEW", "Received or created");
    repository.AddCode("COMP", "Completed");
    repository.AddCode("ACK", "Acknowledged");
    // ... 7 further Add/AddCode call(s) through line 36 (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
-- AddCode pattern (SharedExtensions.cs:26-27), issued 10 time(s); first call shown ('NEW', 'Received or created')
SELECT *
FROM (
  SELECT 1
  FROM EBILL_BATCH_STATUS_CODE EBSC
  WHERE EBSC.CODE = :code
    AND EBSC.CODE_DESCR = :description)
WHERE ROWNUM <= 1

-- only when the probe returns no row
INSERT INTO EBILL_BATCH_STATUS_CODE (
  CODE,
  UPDATE_NUM,
  CODE_DESCR,
  UPDATE_USER,
  UPDATE_DATE)
VALUES (
  :Code,
  :UpdateNumber,
  :Description,
  :UpdateUser,
  :UpdateDate)

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 (10 calls, lines 24-36). - Columns not set by AddCode are written as NULL (or the mapped default) in the INSERT. - "EOB" is added twice (lines 29 and 34); the second probe finds the row and skips the INSERT.

Sources

  • Data/SAIF.Data/TestRepository/RepositoryExtensions/EbillingExtensions.cs:14