Ich habe diese einfache LINQ-AbfrageNULL Handhabung in DbContext und Object
from e in Employees
where e.DesignationID !=558
select e
Hier DesignationID
ein Nullable-Feld ist:
In objectcontext
die Abfrage übersetzt:
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]
Während die gleiche Abfrage in dbcontext
wird übersetzt in:
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))
Warum behandelt objectcontext
NULL anders als dbcontext
?