DapperLib / DapperLib/Dapper

Nullable input parameter not supplied when NULL

Open
#2,187 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage
Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

Using Dapper 2.1.66 in a C# dotnet10 solution, connecting to a Dataverse database (TDS)...

My code is :

var queryParams = new
{
	FirstName = person.FirstName,
	LastName = person.LastName,
	Email = person.Email,
	AccountId = request.CompanyId
};

var contactId = await sqlConnection.QueryFirstOrDefaultAsync<Guid?>(Data.Queries.FindContactsForRegistration, queryParams);

The first 3 parameters are non-nullable strings.
The fourth parameter is a nullable GUID (uniqueidentifier).

My error output is :
The parameterized query '(@FirstName nvarchar(200),@LastName nvarchar(200),@Email nvarcha' expects the parameter '@AccountId', which was not supplied.

It suggests Dapper isn't providing the @AccountId parameter to the query, when its value is NULL.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the QueryFirstOrDefaultAsync call and the Data.Queries.FindContactsForRegistration query; reproduce the nullable AccountId case against the reported Dataverse/TDS setup. Trace how Dapper binds the anonymous object's nullable GUID and compare the generated parameters; done means the query receives @AccountId when null, with regression coverage for the case.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.