Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LINQ to SQL SOUNDEX - possible?

I have done a little bit of research on this and looked through a few articles both here on StackOverflow as well as some blog posts, but haven't found an exact answer. I also read that it is possible to do it using the 4.0 framework, but have yet to find any supporting evidence.

So my question, is it possible to perform SOUNDEX via a LINQ to SQL Query?

like image 816
Steve Hayes Avatar asked Jun 07 '10 20:06

Steve Hayes


2 Answers

Since .net 4 this will work as well:

from p in mytable
where SqlFunctions.SoundCode(p.MyRow) == SqlFunctions.SoundCode("test")
select p

More info here: http://msdn.microsoft.com/en-us/library/system.data.objects.sqlclient.sqlfunctions.soundcode.aspx

like image 60
Marthijn Avatar answered Sep 21 '22 09:09

Marthijn


You can also use the SqlFucntions.Difference method, which maps to the Soundex function:

SqlFunctions.Difference(string, string) returns int - the higher the return value, the more "similar" the strings are.

like image 24
Mark Shapiro Avatar answered Sep 18 '22 09:09

Mark Shapiro