Tôi có điều này truy vấn LINQ đơn giảnxử lý NULL trong dbcontext và ObjectContext
from e in Employees
where e.DesignationID !=558
select e
Đây DesignationID
là một lĩnh vực nullable:
Trong objectcontext
truy vấn được phiên dịch sang:
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]
Trong khi cùng một truy vấn trong dbcontext
nó được dịch sang:
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))
Tại sao objectcontext
xử lý NULL khác với dbcontext
?