【发布时间】:2012-01-29 00:08:48
【问题描述】:
我想根据我的结果和我的字符串行中的匹配数进行排序。
这里是代码
.ThenByDescending(p => p.Title.ToLower()
.Split(' ')
.Count(w => words.Any(w.Contains)));
但它给我带来了错误,并说 LINQ 无法将 Split 解析为 SQL。
LINQ to Entities 无法识别方法“System.String[] Split(Char[])' 方法,并且这个方法不能翻译成 存储表达式。
如何通过 LINQ 实现拆分?
例如,对于这个数组,它必须以这种方式排序
words = { "a", "ab" }
ab a ggaaag gh //3 matches
ba ab ggt //2 matches
dd //0 matches
【问题讨论】:
标签: c# .net linq exception-handling linq-to-entities