Skip to content

SQL-254: TaskExtensions.FillTaskCategory

This statement is a create operation invoked through ORM (IRepository.Add). Executed by TaskExtensions.FillTaskCategory.

Classification

Field Value
SQL ID SQL-254
Operation type Create
Execution method ORM (IRepository.Add)
Database Oracle*
Schema [unqualified]**
Command type N/A (ORM-generated)
Business object TaskExtensions
Criteria property N/A — ORM
Lifecycle method FillTaskCategory

Tables

Table Access Columns used
TASK_CATEGORY_CODE INSERT ×6 (hypothetical) Code, CODE_DESCR, NOTEPAD_REQUIRED_FLAG, DEFAULT_ACTION_CODE, DEFAULT_PRIORITY_CODE, TASK_SOURCE_CODE

LINQ statement

Source: Data/SAIF.Data/TestRepository/RepositoryExtensions/TaskExtensions.cs:47.

// Data/SAIF.Data/TestRepository/RepositoryExtensions/TaskExtensions.cs:45-110
private static void FillTaskCategory(IUnitOfWork uow)
{
    var repo = uow.GetRepository<TaskCategory>();
    var med = uow.GetRepository<TaskPriority>().Query().SingleOrDefault(x => x.Code == "MED");
    var info = uow.GetRepository<TaskPriority>().Query().SingleOrDefault(x => x.Code == "INFO");
    var act = uow.GetRepository<TaskAction>().Query().SingleOrDefault(x => x.Code == "NONE");
    var image = uow.GetRepository<TaskSource>().Query().SingleOrDefault(x => x.Code == "IMAGE");
    var wcis = uow.GetRepository<TaskSource>().Query().SingleOrDefault(x => x.Code == "WCIS");

    repo.Add(new TaskCategory
    // ... 5 further Add/AddCode call(s) through line 110 (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
INSERT INTO TASK_CATEGORY_CODE (
  Code,
  CODE_DESCR,
  NOTEPAD_REQUIRED_FLAG,
  DEFAULT_ACTION_CODE,
  DEFAULT_PRIORITY_CODE,
  TASK_SOURCE_CODE)
VALUES (
  :Code,
  :Description,
  :IsNotepadRequired,
  :DefaultAction,
  :DefaultPriority,
  :TaskSource)
-- issued 6 time(s), lines 54-110

Translation notes: - Not accessed: TASK_PRIORITY_CODE, TASK_ACTION_CODE, TASK_SOURCE_CODE — the lookups at lines 48-52 are separate statements (SQL-305/306/307); in the INSERT they contribute FK values only. - Id(Code) column is literally Code. NOTEPAD_REQUIRED_FLAG is YesNoType.

Sources

  • Data/SAIF.Data/TestRepository/RepositoryExtensions/TaskExtensions.cs:47