Skip to content

SQL-375: Delete DocumentTemplateOption via DeleteTemplateOptions

This statement deletes each DocumentTemplateOption entity in a set of detached copies produced for a given template, via IUnitOfWork.GetRepository<T>().Delete(entity) inside a foreach loop, invoked from TemplateSearchService.DeleteTemplateOptions (Services/SAIF.Services/Documents/TemplateSearchService.cs:850). One DELETE is issued per row (DOCUMENT_OPTION_SEQ_NUM). The SQL below is inferred from this repository call and the DocumentTemplateOption NHibernate mapping — it is not literal SQL present in source.

Classification

Field Value
SQL ID SQL-375
Operation type Delete
Execution method ORM (IRepository.Delete)
Database Oracle
Schema [unqualified]**
Command type N/A (ORM-generated)
Business object DocumentTemplateOption
Criteria property N/A — ORM
Lifecycle method DeleteTemplateOptions

Parameters

Parameter Direction Type Max length Description
:Id Input long N/A Identifier of the DocumentTemplateOption being deleted (DOCUMENT_OPTION_SEQ_NUM)

Tables

Table Access Columns used
DOCUMENT_TEMPLATE_OPTION DELETE DOCUMENT_OPTION_SEQ_NUM

LINQ statement

Source: Services/SAIF.Services/Documents/TemplateSearchService.cs:850

// Services/SAIF.Services/Documents/TemplateSearchService.cs:848
foreach (var result in results)
{
    unitOfWork.GetRepository<DocumentTemplateOption>().Delete(result);

Sample SQL

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
DELETE FROM DOCUMENT_TEMPLATE_OPTION
WHERE DOCUMENT_OPTION_SEQ_NUM = :Id

Translation notes:

  • results are detached copies produced by Mapper.Map<DocumentTemplateOption[]>(GetOptionsForOneTemplate(templateId)) (line 844); NHibernate deletes each by identifier.
  • The mapping's Map(x => x.DocumentTemplateSeqNum).Column(" DOCUMENT_TEMPLATE_SEQ_NUM") has a leading space in source (line 14); not used by this DELETE.

Operations and processes

Sources

  • Services/SAIF.Services/Documents/TemplateSearchService.cs (L850)