剑道过滤器
if ($.trim(DepartmentId)) { $filter.push({ field: "DepartmentId", operator: "eq", value: DepartmentId }); }
模型
public System.Guid DepartmentId { get; set; }
方法
[Queryable]
public IQueryable<Employee> Get(ODataQueryOptions opts)
{
EmployeeService.HrEmployeeServiceFacadeClient emp = new EmployeeService.HrEmployeeServiceFacadeClient();
var response = emp.GetAll();
List<Employee> result = JsonConvert.DeserializeObject<List<Employee>>(response.Result);
var resultString = result.AsQueryable();
return resultString;
}
我使用OData 2.2
显示错误
检测到具有不兼容类型的二元运算符。找到操作数类型&#39; Edm.Guid&#39;和&#39; Edm.String&#39;对于运营商类型&#39; Equal&#39;。
答案 0 :(得分:4)
在OData v2中,必须将文字GUID序列化为guid'dddddddd-dddd-dddd-dddd-dddddddddddd'
,其中每个d
代表一个十六进制数字。