0
votes

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?

1

1 Answers

1
votes

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.