I have this simple LINQ query
from e in Employees
where e.DesignationID !=558
select e
Here DesignationID
is a nullable field:
In objectcontext
the query is translated to:
SELECT
[Extent1].[EmployeeID] AS [EmployeeID],
[Extent1].[EmployeeCode] AS [EmployeeCode],
[Extent1].[EmployeeName] AS [EmployeeName],
[Extent1].[DesignationID] AS [DesignationID]
FROM [dbo].[setupEmployees] AS [Extent1]
WHERE 558 <> [Extent1].[DesignationID]
While the same query in dbcontext
it is translated to:
SELECT
[Extent1].[EmployeeID] AS [EmployeeID],
[Extent1].[EmployeeCode] AS [EmployeeCode],
[Extent1].[EmployeeName] AS [EmployeeName],
[Extent1].[DesignationID] AS [DesignationID]
FROM [dbo].[setupEmployees] AS [Extent1]
WHERE NOT ((558 = [Extent1].[DesignationID]) AND ([Extent1].[DesignationID] IS NOT NULL))
Why does objectcontext
handle NULL differently than dbcontext
?