当从我的Kendo OData调用ListView时,我得到了以下异常:
“检测到一个类型不兼容的二进制运算符。为运算符类型‘等于’找到操作数类型'Edm.Guid‘和'Edm.String’。”
解码滤波器:
$filter=OrganizationId eq '4c2c1c1e-1838-42ca-b730-399816de85f8‘
编码滤波器:
%24filter=OrganizationId+eq+%274c2c1c1e-1838-42ca-b730-399816de85f8%27
也成功地尝试了这些过滤器:
$filter=OrganizationId eq guid'4c2c1c1e-1838-42ca-b730-399816de85f8‘
$filter=OrganizationId eq铸(‘4c2c1c1e-1838-42ca-b730-399816de85f8’,Edm.Guid)
我的WEB调用看起来像:
// GET: odata/Sites
[HttpGet]
[EnableQuery]
public IHttpActionResult GetSites(ODataQueryOptions<Site> queryOptions)
{
IQueryable<Site> sites = null;
try
{
queryOptions.Validate(_validationSettings);
sites = _siteService.GetAll().OrderBy(x => x.SiteName);
if (sites == null)
return NotFound();
}
catch (ODataException ex)
{
TraceHandler.TraceError(ex);
return BadRequest(ex.Message);
}
return Ok(sites);
}我的JAVASCRIPT看起来像:
var dataSource = new kendo.data.DataSource({
filter: { field: "OrganizationId", operator: "eq", value: that.settings.current.customer.id },
schema: {
data: function (data) {
return data.value;
},
total: function (data) {
return data.length;
}
},
serverFiltering: true,
serverPaging: true,
transport: {
parameterMap: function (options, type) {
var paramMap = kendo.data.transports.odata.parameterMap(options);
// Remove invalid Parameters that Web API doesn't support
delete paramMap.$inlinecount; // <-- remove inlinecount
delete paramMap.$format; // <-- remove format
delete paramMap.$callback; // <-- remove callback
// PLEASE NOTICE: That I have tried reformatting unsuccessfully
//paramMap.$filter = paramMap.$filter.replace("OrganizationId eq ", "OrganizationId eq guid");
//paramMap.$filter = "OrganizationId eq cast('81de6144-987c-4b6f-a9bd-355cb6597fc1', Edm.Guid)";
return paramMap;
},
read: {
url: buildRoute('odata/Sites')
, dataType: 'json'
}
},
type: 'odata'
});发布于 2015-03-13 05:37:34
如果OData服务的协议版本为V4,则正确的查询URL应该是:
$filter=OrganizationId eq 4c2c1c1e-1838-42ca-b730-399816de85f8不需要单引号。
发布于 2018-10-15 19:19:44
我通过MicrosoftDynamics查询OData 4.0时遇到了这个错误。不幸的是,这里的其他答案并没有帮助,尽管它们是完全正确的。我的问题更多的是处理EntityReference的过滤器。
最后,我不得不调整我的过滤器这样的东西,以正确地瞄准外键。在下面的示例中,'parentaccountid‘是我正在查询的实体中的外键。‘'accountid’是帐户实体中的主键。
/opportunities?$select=opportunityid&$filter=parentaccountid/accountid eq 5e669180-be01-e711-8118-e0071b6af2a1发布于 2018-02-22 04:39:09
在ms crm中,对于另一个实体引用具有某种id的每个值都应该这样评估。
$filter=_foodValue eq 593687F4-8B0C-E811-81B1-91CF10505DB5 不需要引号或guid字符串。
https://stackoverflow.com/questions/28995757
复制相似问题