如何在已使用函数时不区分大小写的 odata 查询



我有一个复杂的 odata 查询,我正在使用 OdataAngularResrouce 库通过 Angular。众所周知,odata查询区分大小写,显然我不知道数据是如何存储在数据库中的。这是我用于构建查询的谓词。

var predicFirstName = new $odata.Predicate(new $odata.Func("startswith", "FirstName", new $odata.Func("tolower", $scope.searchObject.searchString)), true);
            var predicLastName = new $odata.Predicate(new $odata.Func("startswith", "LastName", new $odata.Func("tolower", $scope.searchObject.searchString)));
**OData URI:**
https://localhost/app/TylerIdentityUserAdministrationService/Users/$count/?$filter=((startswith(FirstName,tolower(Fahad)))%20or%20startswith(LastName,tolower(Fahad)))

如您所见,我想放置一个函数来仅检查带有 startswith 的给定字符串。我看过几篇帖子,其中的解决方案是将 tolower()。但是,当我以上面提到的方式放置它时,它不会返回任何数据。有人可以在这里帮忙吗?

谢谢-法赫德

$filter中的属性和文本字符串都需要转换为小写。由于文本字符串源自客户端,因此可以在发送 OData 请求之前将其转换为小写来优化。

$filter=startswith(tolower(FirstName),'fahad') or startswith(tolower(LastName),'fahad')

请注意,文本字符串必须在筛选器表达式中用单引号括起来。

最新更新