The key is to use the SqlFunctions object found in System.Data.Objects.SqlClient, e.g.
var query = dataContext.Agencies.AsQueryable(); if (!string.IsNullOrEmpty(searchTerm)) { query = query.Where(agency => agency.Name.Contains(searchTerm) || SqlFunctions.SoundCode(agency.Name) == SqlFunctions.SoundCode(searchTerm)); }
Thanks for this James. Any idea how to sort the results by relevance in this case?
ReplyDeleteWould like to know how to Sort or Order By weight.
ReplyDeleteThanks James
ReplyDelete