0

I have Sql table that contains two fields Title and Description, I use LINQ to SQL for all datbase operations, how would I get similar items depending on the item that I am currently showing to the user, I know this can be done by using Full Text Search in SQL but LINQ to SQL doesn't support it.

Can someone explain me logic beheind this, or show me example how it's done? Should I split Title and Description on words and then search the table or? SO similar questions system seems perfect, how do they do it?

formatc
  • 4,261
  • 7
  • 43
  • 81
  • @kol can you show me an example? – formatc Jun 07 '12 at 16:18
  • Check out the solutions here: http://stackoverflow.com/questions/5374481/like-operator-in-linq – kol Jun 07 '12 at 16:19
  • I deleted my original comment, since regular expressions "have no supported translation to SQL", as the exception says. I hope the LIKE-equivalents in the above SO page will help you. – kol Jun 07 '12 at 16:29
  • 1
    @kol LIKE is not the same as CONTAINS, CONTAINSTABLE, FREETEXT, FREETEXTTABLE. Best bet is to create a UDF See [LINQ-to-SQL---Enabling-Fulltext-searching](http://sqlblogcasts.com/blogs/simons/archive/2008/12/18/LINQ-to-SQL---Enabling-Fulltext-searching.aspx) – Conrad Frix Jun 07 '12 at 16:29
  • @ConradFrix +1 for UDF, good idea – kol Jun 07 '12 at 16:39

1 Answers1

0

There is a function called Contains() , I think It will solve your problem , here is an example about how to use It :

        db = new YourDataContext();
    List<Table> list = new List<Table>();
    list = (from i in db.Table where (i.Item.Contains(curentItem)))select i).ToList();
gwt
  • 2,331
  • 4
  • 37
  • 59