开发者

How to get something like sql '%test%words%' in linq

开发者 https://www.devze.com 2023-01-18 04:28 出处:网络
I know how to use .Contains for looking up \'%testwords%\', my question is about how开发者_如何学Python to use linq to get \'%test%words%\'. Thanksmaybe something like this if you\'re not using Linq t

I know how to use .Contains for looking up '%testwords%', my question is about how开发者_如何学Python to use linq to get '%test%words%'. Thanks


maybe something like this if you're not using Linq to SQL:

var query = from o in yourObject
            where  o.field.Contains("test")
            where o.field.Contains("words")
            where o.field.indexOf("test") < o.field.indexOf("words")
            select o;

if you are using Linq to SQL, use the SqlMethods that Stefanvds showed.


.Where(q => SqlMethods.Like(q,"%test%words%"))

use SqlMethods


well, i think the answer is NO :(

Probably the closest answer is lst.Where(foo.Contains("test") && foo.Contains("word")), though that statement doesnt give the right sequence as '%test%word%'

0

精彩评论

暂无评论...
验证码 换一张
取 消