SQL-198: Retrieve GroupAssociation via GroupQuery¶
This covers four GroupAssociation reads built on the GroupQuery() queryable in GroupService: an unfiltered list, a search by acronym/name substring, a single-row lookup by acronym, and a single-row lookup by id.
Classification¶
| Field | Value |
|---|---|
| SQL ID | SQL-198 |
| Operation type | Read |
| Execution method | ORM (NHibernate LINQ) |
| Database | Oracle |
| Schema | [unqualified]** |
| Command type | N/A (ORM-generated) |
| Business object | GroupService |
| Criteria property | N/A — ORM |
| Lifecycle method | GroupQuery |
Parameters¶
| Parameter | Direction | Type | Max length | Description |
|---|---|---|---|---|
:searchTermUpper |
Input | String | N/A | searchTerm.ToUpper(), client-side — filters code_acronym / code_descr |
:acronymUpper |
Input | String | N/A | acronym.ToUpper(), client-side — filters code_acronym |
:idUpper |
Input | String | N/A | id.ToUpper(), client-side — filters code |
Tables¶
| Table | Access | Columns used |
|---|---|---|
| GROUP_ASSOCIATION | SELECT | code, code_descr, phone, code_acronym, association_exp_date, group_representative, group_type_code, parent_group |
LINQ statement¶
Source: Services/SAIF.Services/Groups/GroupService.cs:67 (queryable-property definition). Consumers are at lines 41, 47, 54, and 60.
// Services/SAIF.Services/Groups/GroupService.cs:67
return unitOfWork.GetRepository<groupsDataModel.GroupAssociation>().Query();
// Services/SAIF.Services/Groups/GroupService.cs:41
var dataGroups = GroupQuery().ToList();
// Services/SAIF.Services/Groups/GroupService.cs:47
var dataGroups = GroupQuery().Where(g => g.Acronym.ToUpper().Contains(searchTerm.ToUpper())
|| g.Name.ToUpper().Contains(searchTerm.ToUpper())).ToList();
// Services/SAIF.Services/Groups/GroupService.cs:54
var dataGroup = GroupQuery().FirstOrDefault(g => g.Acronym.ToUpper() == acronym.ToUpper());
// Services/SAIF.Services/Groups/GroupService.cs:60
var dataGroup = GroupQuery().FirstOrDefault(g => g.Id.ToUpper() == id.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
-- Base: GroupQuery() (GroupService.cs:67) — IQueryable only.
-- (1) L41 — GetGroupSearchList()
SELECT GA.code,
GA.code_descr,
GA.phone,
GA.code_acronym,
GA.association_exp_date,
GA.group_representative,
GA.group_type_code,
GA.parent_group
FROM group_association GA
-- (2) L47 — GetGroupSearchList(searchTerm)
SELECT GA.code, GA.code_descr, GA.phone, GA.code_acronym, GA.association_exp_date,
GA.group_representative, GA.group_type_code, GA.parent_group
FROM group_association GA
WHERE UPPER(GA.code_acronym) LIKE '%' || :searchTermUpper || '%'
OR UPPER(GA.code_descr) LIKE '%' || :searchTermUpper || '%'
-- (3) L54 — GetGroupHeader
SELECT * FROM (
SELECT GA.code, GA.code_descr, GA.phone, GA.code_acronym, GA.association_exp_date,
GA.group_representative, GA.group_type_code, GA.parent_group
FROM group_association GA
WHERE UPPER(GA.code_acronym) = :acronymUpper
) WHERE ROWNUM <= 1;
-- (4) L60 — GetGroup
SELECT * FROM (
SELECT GA.code, GA.code_descr, GA.phone, GA.code_acronym, GA.association_exp_date,
GA.group_representative, GA.group_type_code, GA.parent_group
FROM group_association GA
WHERE UPPER(GA.code) = :idUpper
) WHERE ROWNUM <= 1;
Translation notes:
- GroupQuery() is a private method returning IQueryable; consumers are L41, L47, L54, and L60.
- FirstOrDefault uses the Oracle10 dialect wrapper SELECT * FROM (...) WHERE ROWNUM <= 1.
- No joins appear in this SQL. The AutoMapper profile (L34-35) reads dg.Type.Description for GroupHeader, which lazy-loads the group-type code row in a separate statement; dg.Type.Code is served from the FK.
Operations and processes¶
- GroupService.GroupQuery — see Operations and processes
Sources¶
Services/SAIF.Services/Groups/GroupService.cs (L67)