1

I can use linq to sql to match a part of a string with

From C In DB.City Where C.Name.Contains(Query)

What i need to do for it to match only beginning of words? (Behave like full text index)

ariel
  • 15,620
  • 12
  • 61
  • 73

1 Answers1

4

You can check if the first word starts with the query by using StartsWith instead of Contains:

C.Name.StartsWith(Query)

This only checks the first word, not all words in the string.

You can't do a full text search directly using LINQ. What you can do instead is create a stored procedure to do the full text search and call that using LINQ.

Related question:

See also:

Community
  • 1
  • 1
Mark Byers
  • 811,555
  • 193
  • 1,581
  • 1,452