我有这个简单的LINQ查询NULL处理中的DbContext和ObjectContext的
from e in Employees
where e.DesignationID !=558
select e
这里DesignationID
是一个可空场:
在objectcontext
查询被翻译为:
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]
虽然相同查询在dbcontext
它被翻译为:
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))
为什么objectcontext
处理空值与dbcontext
不同?