I have this LINQ query
dbContext.Customers.Where(c => c.AssetTag == assetTag).Count();
or
(from c in dbContext.Customers
where c.AssetTag == assetTag
select c).Count();
The generated SQL is
SELECT
[GroupBy1].[A1] AS [C1]
FROM ( SELECT
COUNT(1) AS [A1]
FROM [dbo].[Customer] AS [Extent1]
WHERE (([Extent1].[AssetTag] = @p__linq__0) AND ( NOT ([Extent1].[AssetTag] IS NULL OR @p__linq__0 IS NULL))) OR (([Extent1].[AssetTag] IS NULL) AND (@p__linq__0 IS NULL))
) AS [GroupBy1]
So why does LINQ generate such complex SQL for a simple where statement?