簡體   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