How to get rank from full-text search query with Linq to SQL?
Posted
by Stephen Jennings
on Stack Overflow
See other posts from Stack Overflow
or by Stephen Jennings
Published on 2010-05-09T04:22:56Z
Indexed on
2010/05/09
4:28 UTC
Read the original article
Hit count: 688
I am using Linq to SQL to call a stored procedure which runs a full-text search and returns the rank plus a few specific columns from the table Article
. The rank column is the rank returned from the SQL function FREETEXTTABLE(). I've added this sproc to the data model designer with return type Article
.
This is working to get the columns I need; however, it discards the ranking of each search result. I'd like to get this information so I can display it to the user.
So far, I've tried creating a new class RankedArticle
which inherits from Article
and adds the column Rank
, then changing the return type of my sproc mapping to RankedArticle
. When I try this, an InvalidOperationException gets thrown:
Data member 'Int32 ArticleID' of type 'Heap.Models.Article' is not part of the mapping for type 'RankedArticle'. Is the member above the root of an inheritance hierarchy?
I can't seem to find any other questions or Google results from people trying to get the rank column, so I'm probably missing something obvious here.
© Stack Overflow or respective owner