Created
June 27, 2012 21:57
-
-
Save neoGeneva/3007125 to your computer and use it in GitHub Desktop.
Full-Text Search From EF4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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