【问题标题】:substring is changed by substringof?substring 被 substringof 改变了?
【发布时间】:2018-06-19 12:50:52
【问题描述】:

我在阅读 MCSD Certification Toolkit (Exam 70-483) 的书时发现了 OData 过滤字符串函数 bool substring(string p0, string p1)

尝试在我的应用程序中使用它:

/Categories?$select=CategoryName&$filter=substring(CategoryName,'Seafood')

得到错误:

No function signature for the function with name 'substring' matches the specified arguments. The function signatures considered are: 

    substring(Edm.String Nullable=true, Edm.Int32); 
    substring(Edm.String Nullable=true, Edm.Int32 Nullable=true);
    substring(Edm.String Nullable=true, Edm.Int32, Edm.Int32); 
    substring(Edm.String Nullable=true, Edm.Int32 Nullable=true, Edm.Int32); 
    substring(Edm.String Nullable=true, Edm.Int32, Edm.Int32 Nullable=true); 
    substring(Edm.String Nullable=true, Edm.Int32 Nullable=true, Edm.Int32 Nullable=true).

看起来所需的子字符串函数不见了?它在哪里?

我发现类似的功能很好用:

/Categories?$select=CategoryName&$filter=substringof(CategoryName,'Seafood')

【问题讨论】:

  • 子字符串存在,但参数中不包含 2 个字符串:string substring(string p0, int pos)string substring(string p0, int pos, int length)
  • 查看 MSDN 文档,substring 从未将两个 String 对象作为参数。你确定这不仅仅是一个错字吗?

标签: c# rest web-services substring odata


【解决方案1】:

也许是因为这个原因:

substringof()V3 函数,而contains()V4 函数。

立即尝试包含:

$filter=contains(Name,'King')

Reference

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-04
    • 2011-11-12
    • 1970-01-01
    • 1970-01-01
    • 2016-06-24
    • 2013-05-24
    相关资源
    最近更新 更多