I have a stored procedure that I'm trying to execute using Dapper that is raising an error that doesn't appear to be pertinent to what I'm trying to do, although I can't seem to figure out what I'm doing wrong.
Here is the signature of the stored procedure that 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's the code that I've written to try 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 being passed in:
And this is the error I'm getting:
"When using the multi-mapping APIs ensure you set the splitOn param if you have keys other than Id Parameter name: splitOn"
UPDATE
The error is being raised from the SqlMapper.GetDynamicSerializer(IDataRecord reader, int startBound, int length, bool returnNullIfFirstMissing)
method. Here's the error location and stack trace:
Any ideas?
I'm using the current version of Dapper (I literally just cloned the repo on Github and pulled SqlMapper.cs into my project just before writing up this question).
I figured out what my problem was here. I was following the examples too literally. My stored procedure doesn't return any values, so SqlMapper
was trying to serialize something that wasn't there. I changed my code to use _cnx.Execute(...)
instead of _cnx.Query(...)
and everything is working fine now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With