views:

343

answers:

1

We are using LINQ to EF to develop a solution.

In my LINQ query I would like

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;

I tried "*" as a wildcard and a regex solution, to no avail -- Are there any other options?

+2  A: 

instead of using Equals try using Contains this should take your wild cards because internally LINQ uses LIKE when you use Contains

var results = from a in mycontainer.users
              where a.fullname.Contains(newString)
              select a.fullname;
Stan R.