LINQ不适用于日语单词

时间:2017-07-14 08:56:03

标签: c# .net linq iqueryable

我有定义为IQueryable的项目列表,我需要深入了解并查找是否有任何字段包含特定字词。当我使用foreach并循环使用它并使用.Contains时,一切正常。问题是我需要使用LINQ和.Boost,因为当我在其中找到单词时,某些字段具有更高的优先级。 当我使用LINQ时,我没有得到任何结果。对于大多数语言,LINQ工作正常,但对于日语单词则没有。有人可以解释我为什么foreach与.Contains工作正常,LINQ与.Where没有?

代码示例:

        foreach (var item in itemList)
        {
            if ((item.PageHeadings != null && item.PageHeadings.Contains(keyword)) ||
                (item.PageName != null && item.PageName.Contains(keyword)) ||
                (item.MetadataDescription != null &&
                 item.MetadataDescription.Contains(keyword)) ||
                (item.MetadataKeywords != null &&
                 item.MetadataKeywords.Contains(keyword)) ||
                (item.ExpandedContent != null &&
                 item.ExpandedContent.Contains(keyword)))
            {

                list.Add(item.Name);
            }

        }

LINQ示例:

         list.AddRange(from item in itemList where (item.PageHeadings != null 
    && item.PageHeadings.Contains(keyword).Boost(BoostPageHeading)) 
    || (item.PageName != null && item.PageName.Contains(keyword).Boost(BoostPageName)) 
    || (item.MetadataDescription != null && item.MetadataDescription.Contains(keyword).Boost(BoostMetadataDescription)) 
|| (item.MetadataKeywords != null && item.MetadataKeywords.Contains(keyword).Boost(BoostMetadataKeywords)) 
    || (item.ExpandedContent != null && item.ExpandedContent.Contains(keyword).Boost(BoostExpandedContent)) select item.Name);

谢谢

更新: 短语的例句:天窓使用例

0 个答案:

没有答案