OData相关字段选择语法

时间:2010-11-17 21:35:42

标签: sql wcf odata

只是想知道将相关字段添加到select语句的正确语法是什么。示例员工都有一个部门,该部门在Employee表的departmentID字段中设置。如果我想撤回所有员工但只想显示他们的FirstName和DepartmentName,那么OData select语法是什么?我以为它会像http://example.com/odata.svc/Employees?$ select = FirstName,+ Department.DepartmentName

1 个答案:

答案 0 :(得分:3)

语法为:http://mywebsite.com/odata.svc/Employees?$select=FirstName,Department/DepartmentName&$expand=Department

Stack Overflow的OData API的相关(工作)示例如下: http://odata.stackexchange.com/stackoverflow/atom/Users?$select=DisplayName,Badges/Name&$expand=Badges