【问题标题】:Like Operator equivalent in LINQ类似于 LINQ 中的等效运算符
【发布时间】:2010-04-28 10:57:03
【问题描述】:
我需要在 LINQ 查询中使用 like 运算符
为此:
timb = time.Timbratures.Include("Anagrafica_Dipendente")
.Where(p => p.Anagrafica_Dipendente.Cognome + " " + p.Anagrafica_Dipendente.Nome like "%ci%");
我该怎么做?
【问题讨论】:
标签:
asp.net
entity-framework
linq
sql-like
【解决方案1】:
timb = time.Timbratures.Include("Anagrafica_Dipendente")
.Where(p => (p.Anagrafica_Dipendente.Cognome + " "
+ p.Anagrafica_Dipendente.Nome).Contains("ci"));
【解决方案2】:
您可以像这样使用 Contains():
var query = (from p in products
where p.Description.Contains("ci")
select p);