allList = allList.Where(c => isAdvertSearchable
&& c.tblAdvert.AdvertTitle.ToLower().Trim().Contains(param.sSearch.ToLower())
|| isTranastionTypeSearchable
&& c.IsActive.ToString().ToLower().Trim().Contains(param.sSearch.ToLower())
|| (c.Amount.ToString().ToLower().Contains(param.sSearch.ToLower().ToString())
|| param.sSearch == "")
|| isTranastionIDSearchable
&& c.TransactionId.ToLower().Trim().Contains(param.sSearch.ToLower())
-
try to put code with in { } bracketsshankar.parshimoni– shankar.parshimoni2014-12-15 05:28:48 +00:00Commented Dec 15, 2014 at 5:28
-
possible duplicate of LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expressionGraemeMiller– GraemeMiller2015-03-02 13:15:46 +00:00Commented Mar 2, 2015 at 13:15
Add a comment
|
1 Answer
LINQ is complaining about not being able to translate ToString to T-SQL.
Use
SqlFunctions.StringConvert(param.sSearch.ToLower())
SqlFunctions Class
Provides common language runtime (CLR) methods that call functions in the database in LINQ to Entities queries.
http://msdn.microsoft.com/en-us/library/system.data.objects.sqlclient.sqlfunctions(v=vs.110).aspx