.netlinqjoindatasetstrongly-typed-dataset

Linq JOIN on a strongly typed dataset where comparator contains DbNull throws exception


Consider the query:

Dim orgs = From g In dbDS.gi_game
            Join o In dbDS.gi_organisation On g.DeveloperID Equals o.ID
            Select o

This will throw an exception when g.DeveloperID is DBNull (this is by design - changing DBNull to any other value is not an option):

System.Data.StrongTypingException: 'The value for column 'DeveloperID' in table 'gi_game' is DBNull.'

I tried this:

Dim orgs = From g In dbDS.gi_game
            Join o In dbDS.gi_organisation On g.DeveloperID Equals o.ID
            Where Not g.IsDeveloperIDNull
            Select o

But hit the same error upon the query enumeration. How do I control for dbnulls?

UPDATE:

Thanks to Shaybakov's answer below, problem solved by mixing linq and lambda. vb.net code:

Dim orgs = From g In dbDS.gi_game.Where(Function(x) x.IsDeveloperIDNull = False)
            Join o In dbDS.gi_organisation On g.DeveloperID Equals o.ID
            Select o

Solution

  • c# syntax

    From g In dbDS.gi_game.Where(x=>!x.IsDeveloperIDNull())
            Join o In dbDS.gi_organisation On g.DeveloperID Equals o.ID
            Select o