Linq to Querystring substringof

时间:2017-04-10 13:58:28

标签: c# asp.net linq

我有一个带有linktoquerystring的asp.net web api:link

Asp.net控制器:

[HttpGet]
[LinqToQueryable]
[Route("")]
public IQueryable<ApplicationViewModel> All()
{
    return _applicationRepository.All();
}

Api网址:

http://localhost:61036/api/customers?$filter=substringof('s', name);

问题:api返回:

"message": "An error has occurred.",
"exceptionMessage": "Object reference not set to an instance of an object.",
"exceptionType": "System.NullReferenceException",

1 个答案:

答案 0 :(得分:1)

已经发现问题,错误的文档doc

substringof /Customers?$filter=substringof(‘Alfreds’, CompanyName) eq true

但必须是

substringof /Customers?$filter=substringof(‘Alfreds’,CompanyName) eq true

所以'Alfreds'和CompanyName之间没有空格