简体   繁体   English

CAML查询结果错误

[英]Wrong results with CAML Query

I have a problem in generating an expression that will check if it contains a given text with accents or not. 我在生成将检查它是否包含带有重音符号的给定文本的表达式时遇到问题。

But when I realize the search he returns only items with accents and ignore the items without accent, I would like him to return the two results together. 但是,当我意识到搜索时,他只返回带有重音符号的项目,而忽略不带重音符号的项目,我希望他将两个结果一起返回。

He seeks in three fields: "Title", "SINPCSobreProduto" and "SINPCCaracteristicas" 他在三个领域中寻找:“标题”,“ SINPCSobreProduto”和“ SINPCCaracteristicas”

I use the library Camlex 我使用Camlex

code: 码:

var searchConditions = new List<Expression<Func<ListItem, bool>>>();
var searches= new[] {"Código", "Codigo"};
foreach (string search in searches)
{
  searchConditions.Add(x => ((string)x["Title"]).Contains(search));
  searchConditions.Add(x => ((string)x["SINPCSobreProduto"]).Contains(search));
  searchConditions.Add(x => ((string)x["SINPCCaracteristicas"]).Contains(search));
}
var searchExpr = ExpressionsHelper.CombineOr(searchConditions);
expressions.Add(searchExpr);

//here he is returning 196 items and not the 201 items because it is ignoring the 5 items
//that are without the accent.
var camlQuery = Camlex.Query().WhereAll(expressions).ToCamlQuery();

Can anyone help me? 谁能帮我?

looks like you should use WhereAny() instead of WhereAll() in the last call: 看起来您应该在上一次调用中使用WhereAny()而不是WhereAll():

var camlQuery = Camlex.Query().WhereAny(expressions).ToCamlQuery();

I think also that it would be more clear if you would mention in your post that you use Camlex library for creating dynamic query. 我还认为,如果您在帖子中提到使用Camlex库创建动态查询,将会更加清楚。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM