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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…