LINQ to SQL SOUNDEX-可能吗? [英] LINQ to SQL SOUNDEX - possible?

查看:94
本文介绍了LINQ to SQL SOUNDEX-可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此进行了一些研究,并查看了StackOverflow上的一些文章以及一些博客文章,但没有找到确切的答案.我还读到可以使用4.0框架来实现它,但尚未找到任何支持证据.

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.

所以我的问题是,是否可以通过LINQ to SQL查询执行SOUNDEX?

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

推荐答案

您可以通过使用伪造的UDF在数据库中执行此操作;在部分类中,向数据上下文中添加一个方法:

You can do this at the database, by using a fake UDF; in a partial class, add a method to the data context:

[DbFunction(Name = "SoundEx", IsComposable = true)]
public string SoundsLike(string input)
{
    throw new NotImplementedException();
}

您可以将其用作表达式:

You can use as an expression like:

x => db.SoundsLike(x.QuoteValue) == db.SoundsLike("text")

最初的想法来自: 从Linq到Sql的随机行

这篇关于LINQ to SQL SOUNDEX-可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆