質問

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;

" *"を試しましたワイルドカードと正規表現ソリューションとして、無駄に-他のオプションはありますか?

役に立ちましたか?

解決

Equals を使用する代わりに、 Contains を使用してみます。これは、 Contains

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

他のヒント

その方法を説明した素晴らしい記事があります: エンティティフレームワークの正規表現

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top