SQL-082: Retrieve ApplicationCode via ValidateApplicationCode¶
This ORM statement performs a read operation on ApplicationCode via IUnitOfWork.GetRepository<T>(), executed from Services/SAIF.Services/OnlineMessages/OnlineMessagesApiService.cs (L123).
Classification¶
| Field | Value |
|---|---|
| SQL ID | SQL-082 |
| Operation type | Read |
| Execution method | ORM (NHibernate LINQ) |
| Database | Oracle |
| Schema | [unqualified]** |
| Command type | N/A (ORM-generated) |
| Business object | ApplicationCode |
| Criteria property | N/A — ORM |
| Lifecycle method | ValidateApplicationCode |
Parameters¶
| Parameter | Direction | Type | Max length | Description |
|---|---|---|---|---|
application.Trim().ToUpper() |
Input | ** | N/A | x.Code == application.Trim().ToUpper() → column CODE |
Tables¶
| Table | Access | Columns used |
|---|---|---|
| ONLINE_MESSAGE_APP_CODE | SELECT | CODE, CODE_DESCR, UPDATE_DATE, UPDATE_NUM, UPDATE_USER |
LINQ statement¶
Source: Services/SAIF.Services/OnlineMessages/OnlineMessagesApiService.cs:122
// Services/SAIF.Services/OnlineMessages/OnlineMessagesApiService.cs:122-123
var applicationCode =
_unitOfWork.GetRepository<ApplicationCode>().Query().FirstOrDefault(x => x.Code == application.Trim().ToUpper());
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
-- Services/SAIF.Services/OnlineMessages/OnlineMessagesApiService.cs:123
SELECT *
FROM (
SELECT
OMAC.CODE,
OMAC.CODE_DESCR,
OMAC.UPDATE_DATE,
OMAC.UPDATE_NUM,
OMAC.UPDATE_USER
FROM ONLINE_MESSAGE_APP_CODE OMAC
WHERE OMAC.CODE = :application
)
WHERE ROWNUM <= 1
Translation notes:
- application.Trim().ToUpper() operates on a captured method argument, not a mapped column; NHibernate's partial evaluator runs it client-side, so the bind value :application is already trimmed and upper-cased - no TRIM/UPPER appears in SQL.
- FirstOrDefault -> Oracle10 ROWNUM <= 1 wrapper.
Operations and processes¶
- OnlineMessagesApiService.ValidateApplicationCode — see Operations and processes
Sources¶
Services/SAIF.Services/OnlineMessages/OnlineMessagesApiService.cs (L123)