我有以下SQL:
select * from transaction_log where stoptime like '%2008%'
Run Code Online (Sandbox Code Playgroud)
如何用LINQ to SQL语法编写它?
Nic*_*ver 30
如果你想使用文字方法,它是这样的:
var query = from l in transaction_log
where SqlMethods.Like(l.stoptime, "%2008%")
select l;
Run Code Online (Sandbox Code Playgroud)
另一种选择是:
var query = from l in transaction_log
where l.stoptime.Contains("2008")
select l;
Run Code Online (Sandbox Code Playgroud)
如果是日期时间:
var query = from l in transaction_log
where l.stoptime.Year = 2008
select l;
Run Code Online (Sandbox Code Playgroud)
该方法位于System.Data.Linq.SqlClient命名空间中
| 归档时间: |
|
| 查看次数: |
14833 次 |
| 最近记录: |