2017-04-10 56 views
0

我有一個linktoquerystring網頁asp.net API:linkLINQ到查詢字符串substringof

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

已經發現了問題,錯誤的文檔doc

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

,但它必須是

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

所以

之間 '艾爾弗雷德' 和公司沒有空間