Running a Dapper stored procedure throws an ArgumentException about multi-mapping

I have a stored procedure that I am trying to execute using Dapper that causes an error that does not seem appropriate for what I am trying to do, although I cannot understand what I am doing wrong.

Here is the signature of the stored procedure I'm trying to call:

ALTER PROCEDURE [dbo].[stp_UpdateInboundDaf] @InboundType varchar(255), @Id bigint, @UserId bigint, @DonationID bigint = NULL, @StatusId int = NULL, @FinalFlag bit = NULL, @ValidatedFlag bit = NULL, @SignedFlag bit = NULL AS ... 

Here is the code I wrote to call the procedure:

 _cnx.Query("stp_UpdateInboundDaf", new { InboundType = parameters.InboundType, Id = parameters.Id, UserId = parameters.UserId, DonationId = parameters.DonationId, StatusId = parameters.StatusId, FinalFlag = parameters.IsFinal, ValidatedFlag = parameters.Validated, SignedFlag = parameters.Signed }, commandType: CommandType.StoredProcedure); 

These are the parameters that are passed to:

enter image description here

And this is the error I get:

"When using the multiple display APIs, make sure you specify the splitOn parameter if you have keys other than Id Parameter name: splitOn"

UPDATE

The error occurs from the SqlMapper.GetDynamicSerializer(IDataRecord reader, int startBound, int length, bool returnNullIfFirstMissing) method SqlMapper.GetDynamicSerializer(IDataRecord reader, int startBound, int length, bool returnNullIfFirstMissing) . Here's the error location and stack trace:

enter image description here

Any ideas?

I am using the current version of Dapper (I literally just cloned the repo on Github and pulled SqlMapper.cs into my project before writing this question).

+4
source share
1 answer

I realized that my problem was here. I have been following examples too closely. My stored procedure does not return any values, so SqlMapper trying to serialize what was not there. I changed my code to use _cnx.Execute(...) instead of _cnx.Query(...) , and now everything works fine.

+10
source

Source: https://habr.com/ru/post/1392086/


All Articles