Moq.Dapper icon indicating copy to clipboard operation
Moq.Dapper copied to clipboard

Add support for null values and strings to First/SingleOrDefault returns

Open tvanfosson-il opened this issue 3 years ago • 0 comments

This pull request adds support for:

  • returning strings from first/singleordefault queries
  • add null returns for reference types for first/singleordefault queries

It does this by modifying the ObjectExtensions to use a switch statement that provides matches for null values and strings before the existing behaviors. Null values use an empty array to convert to the DataTable, while strings use the existing behavior for non-IEnumerables. Since this check needs to happen before the test for the result being IEnumerable, there's a slight duplication that has been documented.

tvanfosson-il avatar Jul 06 '22 23:07 tvanfosson-il