Skip to content

Instantly share code, notes, and snippets.

@neoGeneva
Created June 27, 2012 21:57
Show Gist options
  • Save neoGeneva/3007125 to your computer and use it in GitHub Desktop.
Save neoGeneva/3007125 to your computer and use it in GitHub Desktop.
Full-Text Search From EF4
public static class ObjectQueryExtensions
{
public static ObjectQuery<T> FullTextSearch<T, TProperty>(this ObjectQuery<T> query, Expression<Func<T, TProperty>> propertyExpression, string searchText)
{
var path = string.Join(".", propertyExpression.ToString().Split('.').Skip(1));
return query.Where(string.Format("CONTAINS(it.{0}, @search_text)", path), new ObjectParameter("search_text", searchText));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment