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

查看:22
本文介绍了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天全站免登陆