Why is the sql query different from this linq query when running in C # and on vb.net?

if i run this under c #

from p in Addresses where p.Address2 == null select p.AddressID

it will generate this request

SELECT [t0].[AddressID]
FROM [dbo].[Address] AS [t0]
WHERE [t0].[Address2] IS NULL

if I run it under vb.net

from p in Addresses where p.Address2 = nothing select p.AddressID

it will generate this request

SELECT [t0].[AddressID]
FROM [dbo].[Address] AS [t0]
WHERE [t0].[Address2] = ''

p.Address2 is a varchar field that takes a null value

why is vb.net "wrong"?

+3
source share
1 answer

in VB, checking for zeros is controlled by the keyword "is".

try it;

from p in Addresses where p.Address2 is nothing select p.AddressID
+9
source

Source: https://habr.com/ru/post/1716102/


All Articles