如何把select [field1] from tab where [field1] like '%string1%'转换成linq
如何把select [field1] from tab where [field1] like '%string1%'转换成linq
日期:2014-05-20 浏览次数:20727 次
怎么把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' ------其他解决方案--------------------
var result=db.tab.Where(t=>t.field1.Contains("string1")).Select(t=>t.field1); ------其他解决方案-------------------- 写法很多,首先要了解大概的语句 ------其他解决方案--------------------
from row in tab
where SqlMethods.Like(row.field1 , '%string1%')
select row.field1