简体   繁体   English

LINQ中的类似运算符

[英]Like Operator equivalent in LINQ

I need to use the like operator in a LINQ query 我需要在LINQ查询中使用like运算符

For this: 为了这:

timb = time.Timbratures.Include("Anagrafica_Dipendente")
                .Where(p => p.Anagrafica_Dipendente.Cognome + " " + p.Anagrafica_Dipendente.Nome like "%ci%");

How can I do this? 我怎样才能做到这一点?

timb = time.Timbratures.Include("Anagrafica_Dipendente")
           .Where(p => (p.Anagrafica_Dipendente.Cognome + " "
                       + p.Anagrafica_Dipendente.Nome).Contains("ci"));

You can use Contains() for this like so: 您可以这样使用Contains():

var query = (from p in products
            where p.Description.Contains("ci")
            select p);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM