I’m using VB.NET and Linq to SQL to do search query. I’m using the Contains method of Linq to look up the input keyword. It’s like this note.note_content.Contains(InputKeyWord).
The problem is that If I search for the “cord” then “according” will also come up. I want the result to be matched with keyword only.
How do I do to search for the whole keyword with Linq ?
Thank you.
I’m assuming that the inputKeyword can appear at the beginning, any place in between and at the end of the note, therefore you need to have 3 OR clauses for the 3 possible places where it can appear. So, your LINQ where clause may end up looking like this.
This is not a pretty solution, but It should work. If you are adept with regular expressions, that’s an option with LINQ as well.
Read this: How to Combine LINQ with Regular Expressions