如果我在c#下运行
from p in Addresses where p.Address2 == null select p.AddressID
生成此查询
SELECT [t0].[AddressID]
FROM [dbo].[Address] AS [t0]
WHERE [t0].[Address2] IS NULL
如果我在vb.net下运行
from p in Addresses where p.Address2 = nothing select p.AddressID
生成此查询
SELECT [t0].[AddressID]
FROM [dbo].[Address] AS [t0]
WHERE [t0].[Address2] = ''
p.Address2 是一个接受空值的varchar字段
为什么vb.net是“错误的”?
答案 0 :(得分:9)
在VB中,空检查由“is”关键字控制。
试试这个;
from p in Addresses where p.Address2 is nothing select p.AddressID