I’m having problems searching by first / last / first + last name combinations.
I had it working correctly with first names & last names, but with first+last name combinations it was also listing all of the OTHER members with the same last name. Does the StartsWith method not work the way I’m thinking it does or is there some sort of logical error here?
I tried this way:
predicate = predicate.And(p => query.StartsWith(p.FirstNm) && query.EndsWith(p.LastNm) || query.StartsWith(p.FirstNm));
I also tried this way:
predicate = predicate.And(p => query.StartsWith(p.FirstNm) || query.StartsWith(p.LastNm));
With these names:
John Doe Jane Doe Cody Phillips Cody Fisher
Typing in Cody yields both Cody results. Typing in Cody Fisher yields the correct result.
Typing in John Doe yields both John Doe and Jane Doe. I only want it to yield John Doe.
This may be of some help. I believe you’re misusing the StartsWith method. From what I gather you should instead be using the Like method.
http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/128fe4cf-776d-4200-9f48-7f8dd30dcb34/