【发布时间】:2009-10-22 21:23:41
【问题描述】:
我们正在使用 LINQ to EF 开发解决方案。
在我的 LINQ 查询中我想要
string toMatch = "Matt Cool";
newString = toMatch.Replace(" ", "% ") + "%";
// So here newString is 'Matt% Cool%'
/*Now in my datasource, there is no 'Matt Cool', there's 'Matthew Coolguy'.
I would like this query to return that result.
I would expect this behavior with the
wildcard. It doesn't work*/
var results = from a in mycontainer.users
where a.fullname.equals(newString)
select a.fullname;
我尝试将“*”作为通配符和正则表达式解决方案,但无济于事——还有其他选择吗?
【问题讨论】:
-
我认为您可以将代码的第一部分替换为 newString = toMatch.Replace(" ", "% ") + "%";
-
是的,你是对的,我认为出于某种原因我的显然更明显...... :-)
标签: c# .net entity-framework linq-to-entities wildcard