Empty result set creates SelectListItem Item with NULL parameters?
When calling a stored procedure, using QueryAsync, and the result returns no results, it still creates a SelectListItem with 1 item as an item with "NULL" in the value & text.
can you clarify "returns no results"? perhaps a concrete example - does the stored proc not do a select? and is this QueryAsync() or QueryAsync<T>() for some T ?
SelectListItem isn't a Dapper concept, so I'd also need more context to understand what you're doing here
Apologies, for clarification:
The query returns 0 rows, as it's result (this is expected). We are selecting and Id and Name.
We are only using QueryAsync, with the function return type being an IEnumerable<SelectListItem>
We are only using QueryAsync, with the function return type being an
IEnumerable<SelectListItem>
so... you're using QueryAsync<SelectListItem>(...) ? I'm not just being pedantic - I need to be very precise here: the details matter
I do not believe there is any scenario in which a query returning zero rows, when used in this way, will result in a non-zero number of rows. Can we try to boil this down to a runnable, repeatable example - so that we can investigate? What exactly are you seeing? for example, imagine your code looks like:
var data = await conn.Query<SelectListItem>(sql, args);
What happens if we do:
var count = data.Count();
Debug.WriteLine(count); // or Console.WriteLine, etc
What number do you see there? Is it 1? or 0? And are you absolutely positively 100% sure that your query didn't return a row? Can we check that?