我希望我的用户能够通过部分字符串搜索采购订单(这是INT的),即如果采购订单是123456,则输入456会在结果中输入123456.
我认为这会奏效:
var pop = (from po in ctx.PurchaSEOrders let poid = po.PurchaSEOrderID.ToString() where poid.Contains(term) select new SearchItem { id = poid,label = po.SupplierID,category = "purchaSEOrder" }).ToList();
但是我收到了一个错误
LINQ to Entities does not recognize the method 'System.String ToString()' method,and this method cannot be translated into a store expression.
如何将INT PurchaSEOrderID转换为字符串以使我能够搜索它的片段?
谢谢
解决方法
用这个:
id = sqlFunctions.StringConvert((double)poid)