我有一個搜索框,我想根據TicketID返回結果。然而,當試圖將TicketID轉換爲字符串比較它針對搜索詞串,我收到此錯誤...LINQ to Entities無法識別方法'System.String ToString(Int32)'方法
這裏是我的方法:
public ActionResult Autocomplete(Ticket ticket, string term)
{
var searchTickets = db.Tickets
.Where(t => t.StatusID != 3 &&
Convert.ToString(t.TicketID).StartsWith(term))
.Take(10)
.Select(t => new
{
label = t.Summary
});
return Json(searchTickets, JsonRequestBehavior.AllowGet);
}
我已經試過類似的帖子其他建議如SqlFunctions.StringConvert()
擴展方法,但是,這將引發一個語法錯誤之前項目甚至建...
任何指導將不勝感激。
你應該使用'SqlFunctions'的確,你試過了什麼? – haim770
[LINQ to Entities可能重複無法識別方法'System.String ToString()'方法,並且此方法無法轉換爲存儲表達式](http://stackoverflow.com/questions/5899683/linq-to -entities-does-not-recognized-the-method-system-string-tostring-method) –