Coalesce not working in Access database (MDB)

Posts   
 
    
Puser
User
Posts: 228
Joined: 20-Sep-2012
# Posted on: 01-Nov-2016 14:34:38   

hi, i'm working with LLBLGEN pro 5.0 and use both Access and Sql Server. When creating a linq expression with a null coalescing operator in an IQueryable, for instance:

...   LandId = LandId ?? 0,

(First LandId is int, second (database property) LandId is Nullable<int>)

then this gets converted to

COALESCE([LPA_L4].[LandID],
                      @p2)              AS [LandId], 

in SQL code in both Access and Sql Server. But this is not supported in Access. I have managed to work around this by using the following syntax:

... LandId = (LandId ==null ? 0 : LandId )

This gets rather problematic because I use the former syntax a lot and everytime I use this in IQueryables I discover my mistakes only in runtime. When using Nullable<int> to int this gets even more cumbersome for I have to cast the last expression LandId to int as per

... LandId  = (LandId ==null ? 0 : (int)LandId )

that would probably transformed to something like:

...          IIF(IIF(([LPA_L4].[LandID] IS NULL),
                     1,
                     0) = 1,
                 @p2,
                 [LPA_L4].[LandID])    AS [LandId],

Could you please generate the same SQL as you would in second example for the first null coalesce expression? For Access databases only.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 01-Nov-2016 22:43:16   

Which runtime library version (build no.) are you using?

ref: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7717

Puser
User
Posts: 228
Joined: 20-Sep-2012
# Posted on: 02-Nov-2016 08:57:07   

sorry,

5.0 (5.0.1) RTM 05-mei-2016

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 02-Nov-2016 10:32:48   

Likely a bug in the Access function mapping. We'll look into it.

Frans Bouma | Lead developer LLBLGen Pro
Puser
User
Posts: 228
Joined: 20-Sep-2012
# Posted on: 02-Nov-2016 11:30:56   

Thanks Frans!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 02-Nov-2016 11:50:17   

Fixed in 5.0.8 hotfix.

Frans Bouma | Lead developer LLBLGen Pro