IDbConnection.Dictionary() raising exception in 6.9.0


Is there a breaking change with IDbConnection.Dictionary<>() that we’re unaware of in 6.9.0?

Since upgrading to 6.9.0 we’re getting an Object reference not set to an instance of an object exception.

Not that I know of, what’s the best way to repro?

We’ve an endpoint that has two db queries which have historically both worked. Now one works and this one fails…

var activityIdsWithDocuments = Db
                .Dictionary<long, int>(
                        .Where(d =>
                            d.SystemId == identifiedObject.IdentifiedSystemId &&
                            d.OwnerTypeId == (int)identifiedObject.OwnerType &&
                            d.OwnerId == identifiedObject.IdentifiedObjectId)
                        .Select(d => new { d.ActivityId, d.TypeId })

Trying to resolve the 2nd value is throwing the NRE:

Can you confirm if your query always returns non-nullable values. If it doesn’t can you change to use db.Dictionary<long,int?>

1 Like

Doh, if I had a quid for every time nullable values have caused me issues since moving to .net core I’d be able to retire now.

Apologies - I should have been more thorough in testing before I submitted the forum post. It was a slightly different dataset I was testing against.

I’ve tested with int? and its working again - thanks @mythz!

1 Like