I have created an Inline table function in SSMS (called FullSearch()).
From within SSMS I can run a query like
select * from FullSearch('batman')
and the database returns results.
I'm getting an error when calling this function within Linq. I have dragged the function ont my .dbml page (using Linq to Sql) and the compiler recognises it.
My code is
public IQueryable<Models.SearchResults> GetSearchResultsByPhrase(string searchPhrase)
{
IQueryable<Models.SearchResults> videoSearch = (from v in this.FullSearch(searchPhrase)
select new Models.SearchResults
{
ShortDescription = v.shortDescription,
LongDescription = v.LongDescription,
VideoUrl = v.Url
});
return videoSearch;
}
It compiles, but I get the run time error:
Exception Details:
System.Data.SqlClient.SqlException: The full-text query parameter for Fulltext Query String is not valid.
As mentioned, I can run a query using FullSearch within SSMS so I can only assume the fault is with my Linq query, but I'm not sure how. I am passing a one word string (batman) to the Linq query.
DaveRook
Member
582 Points
330 Posts
Linq to SQL and FreeText
Feb 21, 2012 03:39 PM|LINK
Hi
I have created an Inline table function in SSMS (called FullSearch()).
From within SSMS I can run a query like
select * from FullSearch('batman')
and the database returns results.
I'm getting an error when calling this function within Linq. I have dragged the function ont my .dbml page (using Linq to Sql) and the compiler recognises it.
My code is
public IQueryable<Models.SearchResults> GetSearchResultsByPhrase(string searchPhrase) { IQueryable<Models.SearchResults> videoSearch = (from v in this.FullSearch(searchPhrase) select new Models.SearchResults { ShortDescription = v.shortDescription, LongDescription = v.LongDescription, VideoUrl = v.Url }); return videoSearch; }It compiles, but I get the run time error:
Exception Details: System.Data.SqlClient.SqlException: The full-text query parameter for Fulltext Query String is not valid.
As mentioned, I can run a query using FullSearch within SSMS so I can only assume the fault is with my Linq query, but I'm not sure how. I am passing a one word string (batman) to the Linq query.
Any idea what I have done wrong?
Thanks
Dave
DarrellNorto...
All-Star
86555 Points
9624 Posts
Moderator
MVP
Re: Linq to SQL and FreeText
Feb 21, 2012 03:43 PM|LINK
Entity Framework does not natively support FullText searches. Check this workaround:
http://sqlblogcasts.com/blogs/simons/archive/2008/12/18/LINQ-to-SQL---Enabling-Fulltext-searching.aspx
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.
DaveRook
Member
582 Points
330 Posts
Re: Linq to SQL and FreeText
Feb 21, 2012 03:48 PM|LINK
I'm sorry, I don't understand how mine differs from the article you've shown (although thank you for a quick repsonse).
DaveRook
Member
582 Points
330 Posts
Re: Linq to SQL and FreeText
Feb 21, 2012 03:59 PM|LINK
Actually, this is the answer
http://social.msdn.microsoft.com/Forums/en-US/linqtosql/thread/1a46d676-32f0-44a4-b39f-61a17bccb8e3/
To resolve, make sure the nvarchar size is 4000 (I did this in my database and function)