Linq 查询排序的问题..有点复杂!欢迎指教..
IEnumerable<DataAccess.t_photo_gallery> gallery =
(from g in g_DataContext.t_photo_gallery
where (g.CompanyId == companyID)
&& ((g.PhotoPath == null) ? (false) : (g.PhotoPath.Contains(searchKeyWord))
|| ((g.Keyword == null) ? (false) : (g.Keyword.Contains(searchKeyWord)))
|| ((g.Description == null) ? (false) : g.Description.Contains(searchKeyWord)))
&& (((g.IptcInfo == null) ? (false) : (g.IptcInfo.Contains(itpcExifKeyword)))
|| ((g.ExifInfo == null) ? (false) : g.ExifInfo.Contains(itpcExifKeyword)))
orderby
searchKeyWord != "" ? utility.CalculateStringScore(searchKeyWord,g.Keyword) : 0 这一行报错
,g.ModifiedTime descending
select g).Skip(pageSize * pageIndex).Take(pageSize);
return gallery.ToList();
-----------------------------------------------
报错的那一行是想根据返回的int还排序;
错误信息: Method 'Int32 CalculateStringScore(System.String, System.String)' has no supported translation to
SQL.
希望能得到各位高手的帮助;
根据查询的结果,排序...但不是简单的排序...
------解决方案--------------------单步调试 试试
------解决方案--------------------
------解决方案--------------------感觉类型的问题
C# code
searchKeyWord != "" ? utility.CalculateStringScore(searchKeyWord,g.Keyword) : 0
//searchKeyWord 这个什么类型啊?就算是匿名类型也应该是强类型的吧?Int? String?