与LINQ to Entity Framework匹配的复杂字符串

Mat*_*att 1 .net c# linq-to-entities entity-framework wildcard

我们正在使用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;
Run Code Online (Sandbox Code Playgroud)

我尝试使用"*"作为通配符和正则表达式解决方案,但无济于事 - 还有其他选择吗?

Sta*_* R. 6

而不是使用Equals尝试使用Contains这应该采取你的外卡,因为内部LINQ使用LIKE时使用包含

var results = from a in mycontainer.users
              where a.fullname.Contains(newString)
              select a.fullname;
Run Code Online (Sandbox Code Playgroud)