Skip to content

SQL-276: OnlineSupportExtensions.SeedForOnlineSupport

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

Classification

Field Value
SQL ID SQL-276
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
App_Error INSERT ×135 (hypothetical) App_Error_Seq_Num, App_Name, Error_Date, Environment, Machine_Name, Page_Name, Error_Source, State_Info, Error_Info, User_Name, Deleted_Flag

LINQ statement

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

// Data/SAIF.Data/TestRepository/RepositoryExtensions/OnlineSupportExtensions.cs:96-97
var repo = unitOfWork.GetRepository<ErrorLog>();
CreateTimedRecords(repo);

// Data/SAIF.Data/TestRepository/RepositoryExtensions/OnlineSupportExtensions.cs:14-27
repo.Add(
    new ErrorLog
    {
        ApplicationName = string.Concat("APP", i),
        Environment = environment,
        ErrorDate = errorDate,
        ErrorInformation = errorInfo,
        ErrorSource = string.Concat("SRC", i),
        IsDeleted = false,
        MachineName = string.Concat("MACHINE", i),
        PageName = string.Concat("PAGE", i),
        StateInformation = $"The State of Error {i} ",
        UserName = string.Concat("User", i)
    });

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 App_Error (
  App_Name,
  Error_Date,
  Environment,
  Machine_Name,
  Page_Name,
  Error_Source,
  State_Info,
  Error_Info,
  User_Name,
  Deleted_Flag)
VALUES (
  @ApplicationName,
  @ErrorDate,
  @Environment,
  @MachineName,
  @PageName,
  @ErrorSource,
  @StateInformation,
  @ErrorInformation,
  @UserName,
  @IsDeleted)
SELECT SCOPE_IDENTITY()  -- GeneratedBy.Identity()
-- 9 time frames (lines 105-113) x 15 rows per frame (10 environments x1 + "webs" x5, lines 36-46) = 135

Translation notes: - GetRepository<ErrorLog>() at the cited line only resolves the repository; the writes happen in CreateTimedRecords → CreateRecordsForEnvironment → CreateRecords (repo.Add, line 14). - App_Error_Seq_Num is an identity column, so it is omitted from the INSERT and read back.

Sources

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