Skip to content

SQL-275: OnlineSupportExtensions.SeedForOnlineSupport

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

Classification

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

Tables

Table Access Columns used
ERROR_ENVIRONMENT INSERT ×27, SELECT (hypothetical) ID, ENVIRONMENT_NAME, DESCRIPTION

LINQ statement

Source: Data/SAIF.Data/TestRepository/RepositoryExtensions/OnlineSupportExtensions.cs:60.

// Data/SAIF.Data/TestRepository/RepositoryExtensions/OnlineSupportExtensions.cs:60-61
var environments = unitOfWork.GetRepository<ErrorEnvironment>();
CreateEnvironments(environments);

// Data/SAIF.Data/TestRepository/RepositoryExtensions/OnlineSupportExtensions.cs:116-150
private static void CreateEnvironments(IRepository<ErrorEnvironment> repo)
{
    repo.Add(new ErrorEnvironment { Id = 1, EnvironmentName = "entdev01", Description = "entdev01" });
    repo.Add(new ErrorEnvironment { Id = 2, EnvironmentName = "entdev03", Description = "entdev03" });
    // ... 25 further Add/AddCode call(s) through line 150 (elided)
}

// Data/SAIF.Data/TestRepository/RepositoryExtensions/OnlineSupportExtensions.cs:79
var envs = environments.Query().ToList();

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
INSERT INTO ERROR_ENVIRONMENT (
  ID,
  ENVIRONMENT_NAME,
  DESCRIPTION)
VALUES (
  @Id,
  @EnvironmentName,
  @Description)
-- issued 27 time(s), CreateEnvironments lines 116-150

-- line 79: environments.Query().ToList()
SELECT
  EE.ID,
  EE.ENVIRONMENT_NAME,
  EE.DESCRIPTION
FROM ERROR_ENVIRONMENT EE

Translation notes: - Several rows reuse the same assigned Id (e.g. 14 ×4, 1-9 twice); against a real database these INSERTs would violate the primary key — only the in-memory double tolerates them.

Sources

  • Data/SAIF.Data/TestRepository/RepositoryExtensions/OnlineSupportExtensions.cs:60