繁体   English   中英

CAML查询结果错误

[英]Wrong results with CAML Query

我在生成将检查它是否包含带有重音符号的给定文本的表达式时遇到问题。

但是,当我意识到搜索时,他只返回带有重音符号的项目,而忽略不带重音符号的项目,我希望他将两个结果一起返回。

他在三个领域中寻找:“标题”,“ SINPCSobreProduto”和“ SINPCCaracteristicas”

我使用Camlex

码:

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();

谁能帮我?

看起来您应该在上一次调用中使用WhereAny()而不是WhereAll():

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

我还认为,如果您在帖子中提到使用Camlex库创建动态查询,将会更加清楚。

暂无
暂无

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

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