我有這個在我的查詢:方法 '包含布爾..' 有沒有支持轉換爲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