score:0

i found the solution. applied if on whole new column not just on the specific column in the joining table (rate column) because the null is not originated from the rate column, it is originating from an empty bookingcharge record against a booking (attached to the query as a column .totalcharges) therefore whole column should undergo the if statement (coalescence).

.totalcharges = if(b.bookingcharges.sum(function(o) o.rate) <> nothing, b.bookingcharges.sum(function(o) o.rate), 0)

thanks to namrehs and this so answer.

score:2

try using the if() operator:

dim q = (from b in _db.bookings
    select new with {
        .bid = b.id
        .totalcharges = b.bookingcharges.sum(function(o) if(o.rate,0))
}).tolist()

if that doesn't work, maybe try something like this:

dim q = (from b in _db.bookings
    select new with {
        .bid = b.id
        .totalcharges = b.bookingcharges.where(function(r) r.rate isnot nothing).sum(function(o) o.rate)
}).tolist()

Related Query

More Query from same tag