我有这个在我的查询:方法 '包含布尔..' 有没有支持转换为SQL
var results = (from urls in _context.Urls
join documents in _context.Documents on urls.UrlId equals documents.DocumentId
let words = (from words in _context.Words
join hits in _context.Hits on words.WordId equals hits.WordId
where hits.DocumentId == documents.DocumentId
select words.Text).AsEnumerable<string>()
where urls.ResolvedPath.Contains(breakedQuery, KeywordParts.Url, part) ||
documents.Title.Contains(breakedQuery, KeywordParts.Title, part) ||
documents.Keywords.Contains(breakedQuery, KeywordParts.Keywords, part) ||
documents.Description.Contains(breakedQuery, KeywordParts.Description, part) ||
words.Contains(breakedQuery, KeywordParts.Content, part) ...
,并包含扩展方法:
字符串
public static bool Contains(this string source, IEnumerable<string> values, KeywordParts valuePart, KeywordParts part)
{
if (!string.IsNullOrWhiteSpace(source))
return source.Split(' ').AsEnumerable<string>().Contains(values, valuePart, part);
return false;
}
枚举的(主要方法)
public static bool Contains(this IEnumerable<string> source, IEnumerable<string> values, KeywordParts valuePart, KeywordParts part)
{
if (source != null && source.Count() > 0 &&
values != null && values.Count() > 0 &&
(part == KeywordParts.Anywhere || valuePart == part))
{
foreach (var value in values)
{
var has = false;
var none = (value.StartsWith("-"));
string term = value.Replace("-", "");
if (none)
has = source.Any(q => !q.Contains(value));
else
has = source.Any(q => q.Contains(values));
if (has)
return has;
}
}
return false;
}
并使用Contains方法抛出异常NotSupportedException:方法的布尔Contains(String,IEnumerable`1 [String],KeywordParts,KeywordParts)'没有支持的SQL转换。
其实我想,如果有在租赁的指定条件
非常好,谢谢你。你能给我一个方法来提高执行这个查询的速度吗?因为你知道我正在开发非常基本的网络搜索引擎,这是项目搜索部分的一部分。我检索结果后,我想排序结果按选择每个计算的速度。我将在单独问题中发布费率部分。 – Sadegh 2010-07-18 08:34:22
这里是我的问题http://stackoverflow.com/questions/3274897/simple-rating-algohritm-to-sorting-results-according-to-user-query – Sadegh 2010-07-18 08:58:53