我们在4.0.56中看到了我们之前见过的问题(参见ServiceStack - [Reference] or [Ignore]?的更新3) - 即,正在使用TitleID值填充员工的ID属性。
请求DTO是:
[Route("/employees", "GET")]
public class FindEmployeesRequest : QueryDb<Employee>,
IJoin<Employee, EmployeeType>,
IJoin<Employee, Department>,
IJoin<Employee, Title> {
public int? ID { get; set; }
public int[] IDs { get; set; }
public string UserID { get; set; }
public string[] UserIDs { get; set; }
public int? EmployeeTypeID { get; set; }
public int[] EmployeeTypeIDs { get; set; }
public int? DepartmentID { get; set; }
public int[] DepartmentIDs { get; set; }
public int? TitleID { get; set; }
public int[] TitleIDs { get; set; }
public string LastNameStartsWith { get; set; }
public DateTime[] DateOfBirthBetween { get; set; }
public DateTime[] HireDateBetween { get; set; }
public bool? IsActive { get; set; }
public bool? IsEligibleToOrderLunch { get; set; }
[QueryDbField(Template = "(MONTH({Field}) = {Value})", Field = "DateOfBirth")]
public int? BirthMonth { get; set; }
[QueryDbField(Template = "(DAY({Field}) = {Value})", Field = "DateOfBirth")]
public int? BirthDay { get; set; }
[QueryDbField(Template = "({Field} LIKE '%(Incoming)')", Field = "EmployeeTypeName")]
public bool? IsIncoming { get; set; }
[QueryDbField(Template = "(FirstName LIKE {Value} OR LastName LIKE {Value} OR PreferredName LIKE {Value})", ValueFormat = "%{0}%", Field = "ID")]
public string NameSearch { get; set; }
[QueryDbField(Template = "(FirstName LIKE {Value} OR LastName LIKE {Value} OR PreferredName LIKE {Value} OR Department.Name LIKE {Value} OR Title.Name LIKE {Value})", ValueFormat = "%{0}%", Field = "ID")]
public string BasicSearch { get; set; }
[QueryDbField(Template = "({Field} LIKE {Value})", Field = "EmployeeTypeName", ValueFormat = "%{0}%")]
public string EmployeeTypeSearch { get; set; }
[QueryDbField(Template = "({Field} LIKE {Value})", Field = "DepartmentName", ValueFormat = "%{0}%")]
public string DepartmentSearch { get; set; }
[QueryDbField(Template = "({Field} LIKE {Value})", Field = "TitleName", ValueFormat = "%{0}%")]
public string TitleSearch { get; set; }
}
基本上任何执行&#34; SELECT * FROM&#34;的请求展示了这个问题 - 这里有一些来自Profiler的SQL&#34; / employees?id = 101&amp; fields = *&#34;:
exec sp_executesql N'SELECT *
FROM "Employee" INNER JOIN "EmployeeType" ON
("EmployeeType"."ID" = "Employee"."EmployeeTypeID") INNER JOIN "Department" ON
("Department"."ID" = "Employee"."DepartmentID") INNER JOIN "Title" ON
("Title"."ID" = "Employee"."TitleID")
WHERE "Employee"."ID" = @0',N'@0 int',@0=101
当我自己运行此查询时,&#34;员工&#34;。&#34; ID&#34;是101,但在服务的回复中,它是67(TitleID):
答案 0 :(得分:2)
您不能自己使用裸露的通配符?fields=*
,它需要包含表格前缀,例如?fields=employee.*
为mentioned in the docs,这是手动指定表格中每个字段的简写。