I have this piece of code
return await dbConn.QuerySingleOrDefaultAsync<CacheItem>(sqlQuery, new { clientId, key });
Correct me if I am wrong, if I call QueryFirstOrDefault or QuerySingleOrDefault and there are no records found (or table is empty) then I should get an empty CacheItem, right?
Instead I get null, am I missing something?
P.S. If I add records to the table, then I get a CacheItem object, filled with the values from db.
If CacheItem
is a class
it will return null
. If it is a struct
it will return a default instance of CacheItem