Reputation: 273
I try to convert SQL
to LINK
query
I try this
SQL
query
Select name, count(*) from tblVehicles
WHERE MID = 23065 and name<> '' Group By name
LINQ
query
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()
});
How I use <> in LINQ
?
Upvotes: 1
Views: 110
Reputation: 5770
What could work for you is
where vehvoila.MID == "23065" && !(vehvoila.name == null || vehvoila.name == "")
or just
where vehvoila.MID == "23065" && vehvoila.name != ""
String.IsNullOrEmpty
in not supported in Linq-SQL:
Method 'Boolean IsNullOrEmpty(System.String)' has no supported translation to SQL.
Upvotes: 5