Search code examples
entity-framework-4linqkit

Using PredicateBuilder to match part of word


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.


Solution

  • can you try with IndexOf?

    predicate = predicate.And(p => p.FirstName.IndexOf(searchCriteria.FirstName) > -1);