Solved! Read on for bugfix?
I’ve got at least a couple of services where this happens.
I go in the Locode and choose “select columns”.
If EmpNo
is in the select, I get this error:
Ambiguous column name 'EmpNo'.
OrmLite log:
SQL: SELECT TOP 25 "EmpNo", "EmpNo"
FROM "Employee"
ORDER BY "EmpNo"
Used
OrmLiteConfig.BeforeExecFilter = dbCmd => OrmLiteUtils.PrintSql(); // prints every SQL
to get this log.
Query coming from Locode to the server:
https://localhost:5001/api/QueryEmployees?include=total&take=25&fields=EmpNo%2CEmpNo
400 error.
One such is the employee service. The DTO:
[Route("/employees", "GET")]
[Route("/employees/{EmpNo}", "GET")]
[ValidateRequest("IsAuthenticated")]
public class QueryEmployees
: QueryDb<Employee>, IReturn<QueryResponse<Employee>>, IGet
{
//public int? EmpNo { get; set; }
}
is auto generated by going “DB First”, then using the x
tool.
I have commented out the public int? EmpNo { get; set; }
and also tried commenting out [Route("/employees/{EmpNo}", "GET")]
with no improvements.
The underlying Employee class has no double EmpNo
columns, but take note that EmpNo is tagged with [PrimaryKey]
– I removed this, and then the issue was resolved
public class Employee
{
[AutoIncrement]
public int MDK { get; set; }
public string DataSourceId { get; set; }
public int? ActNo { get; set; }
[PrimaryKey]
public int EmpNo { get; set; }
public int? EmpType { get; set; }
public string EmpTypeName { get; set; }
[Required]
public string FullName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Mobile { get; set; }
public string EMail { get; set; }
public string Title { get; set; }
public string Room { get; set; }
public string CountryISOCode { get; set; }
public string Company { get; set; }
[ForeignKey(typeof(Department), ForeignKeyName = "DepNo")]
public int? DepartmentId { get; set; }
public DateTime? BirthDate { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
// ...
public DateTime? Created { get; set; }
public DateTime LastModified { get; set; }
[Required]
public byte[] RowVersion { get; set; }
public string MgrPath { get; set; }
public string JobCode { get; set; }
}