日期:2014-05-20  浏览次数:20798 次

怎么把select [field1] from tab where [field1] like '%string1%'转换成linq
怎么把select [field1] from tab where [field1] like '%string1%'转换成linq

------解决方案--------------------
from row in tab 
where row.field1.Contains("string1") 
select row.field1
------解决方案--------------------
string.Contains("string")相当于'%string%'
string.StartWith("string")相当于'string%'
string.EndWith("string")相当于'%string'
------解决方案--------------------
探讨
怎么把select [field1] from tab where [field1] like '%string1%'转换成linq

------解决方案--------------------
写法很多,首先要了解大概的语句
------解决方案--------------------
C# code

from row in tab  
  where  SqlMethods.Like(row.field1 ,  '%string1%') 
select row.field1