简体   繁体   中英

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"

I use the library 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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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