Skip to content

SQL-159: LegalQueryProvider.GetAdpEmployeeName

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

Classification

Field Value
SQL ID SQL-159
Operation type Read
Execution method ORM (NHibernate LINQ)
Database Unknown**
Schema Unknown**
Command type N/A (ORM-generated)
Business object LegalQueryProvider
Criteria property N/A — ORM
Lifecycle method GetAdpEmployeeName

Parameters

Parameter Direction Type Max length Description
emplId Input string N/A Method argument of LegalQueryProvider.GetAdpEmployeeName bound into the ORM expression; NHibernate generates the bind variable at runtime

Tables

Table Access Columns used
ADP_EMPLOYEE** SELECT EMPLID (Id), RPT_MGR_EMPLID (resolved via Legends); FirstName / LastName / PreferredName columns unresolved

LINQ statement

Source: Data/SAIF.Data/Queries/Legal/LegalQueryProvider.cs:94-95.

public String GetAdpEmployeeName(string emplId)
{
    if (emplId != null)
    {
        var employee =
            Factory.GetRepository<EmployeeData.Employee>().Query().FirstOrDefault(x => (x.Id == emplId));
        if (employee != null)
        {
            if (employee.PreferredName.IsNullOrWhiteSpace())
                return employee.LastName + ", " + employee.FirstName;
            return employee.LastName + ", " + employee.PreferredName;
        }
    }
    return string.Empty;
}

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
SELECT * FROM (
  SELECT
    E.EMPLID,
    E.RPT_MGR_EMPLID,
    E.FirstName, -- unresolved mapping: Employee.FirstName
    E.LastName, -- unresolved mapping: Employee.LastName
    E.PreferredName -- unresolved mapping: Employee.PreferredName
  FROM ADP_EMPLOYEE E
  WHERE E.EMPLID = :emplId
) WHERE ROWNUM <= 1

Translation notes: - Unresolved mapping (partial). EmployeeData.Employee is not mapped in Data/SAIF.Data.NHibernate/Mappings/**. Legends queries run: - 1. legends chat "Which NHibernate ClassMap maps the entity SAIF.Data.Model.Employees.Employee" --repo-type Framework --docgen --raw → mapped in SAIF.Framework.Data.NHibernate to table ADP_EMPLOYEE. - 2. legends chat "List every column of the ADP_EMPLOYEE table mapped by the Employee ClassMap" --library SAIF.Framework.Data.NHibernate --doc-type database-tables --docgen --raw, repeated with --doc-type api → columns not enumerated. - 3. legends search "EmployeeMap ADP_EMPLOYEE columns EMPLID FIRST_NAME LAST_NAME PREFERRED_NAME" --library SAIF.Framework.Data.NHibernate --docgen --top 10 --raw → no column-level hit. - 4. legends chat "What are the key and column details of the ADP_EMPLOYEE table section" --library SAIF.Framework.Data.NHibernate --doc-type database-tables --docgen --raw → key EMPLID; self-reference RPT_MGR_EMPLID (reporting manager). - Per the skill convention, the C# property names FirstName/LastName/PreferredName stand in for the unknown column names; no column name was invented. Any other columns mapped by the external EmployeeMap are unknown and are omitted from the select list. - Dialect is Oracle10, as for every other repository, via Factory.GetRepository<T>().

Operations and processes

Business rules

Sources

  • Data/SAIF.Data/Queries/Legal/LegalQueryProvider.cs:94