我尝试将 SQL
转换为 LINK
查询
我试试这个
SQL
查询
Select name, count(*) from tblVehicles
WHERE MID = 23065 and name<> '' Group By name
LINQ
查询
var re = (from vehvoila in DB.tblVehicles
where vehvoila.MID='23065' && vehvoila.name
group vehvoila by new{vehvoila.name} into g
select new
{
g.Key.name,
cnt=g.Select(t=>t.name).Count()
});
我如何在 LINQ
中使用 <> ?
最佳答案
对你有用的是
where vehvoila.MID == "23065" && !(vehvoila.name == null || vehvoila.name == "")
或者只是
where vehvoila.MID == "23065" && vehvoila.name != ""
String.IsNullOrEmpty
在 Linq-SQL 中不受支持:
Method 'Boolean IsNullOrEmpty(System.String)' has no supported translation to SQL.
关于c# - sql 到 linq 查询转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37695663/