Fredou
Fredou

Reputation: 20120

why the sql query is different on that linq query when run on c# and on vb.net?

if I run this under c#

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

it generate this query

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

if I run this under vb.net

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

it generate this query

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

p.Address2 is a varchar field that accept null value

why vb.net is "wrong" ?

Upvotes: 3

Views: 91

Answers (1)

Ali Ersöz
Ali Ersöz

Reputation: 16086

in VB, null checks are controlled with "is" keyword.

try this;

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

Upvotes: 8

Related Questions