0

I'm using LinqKit predicate Builder to find a record. I need to match the same as Like %word%

p -> is Customer Class with FirstName, LastName ect....

but when I use:

predicate = predicate.And(p => p.FirstName.Contains(searchCriteria.FirstName));

I get only Exact match. how can I change the code to get partial match (if I look for dani I want to get both "dani" and "daniel" )

Thanks.

Dani
  • 14,639
  • 11
  • 62
  • 110

1 Answers1

1

can you try with IndexOf?

predicate = predicate.And(p => p.FirstName.IndexOf(searchCriteria.FirstName) > -1);
Akhil
  • 7,570
  • 1
  • 24
  • 23
  • Although it looks like a good solution, it doesn't work... (even on exact match) – Dani Jun 07 '11 at 02:42
  • I've found the problem somewhere else in the code. this line was correct as well and it equals to contains. thanks. – Dani Jun 08 '11 at 15:00