Dapper - splitOn doesn't exist

dapper stored-procedures

Question

I'm trying to execute this snippet

var dParams = new DynamicParameters();

dParams.Add("@ShipDate", warranty.ShipDate);
dParams.Add("@WarrantyStartDate", warranty.WarrantyStartDate);
dParams.Add("@WarrantyEndDate", warranty.WarrantyEndDate);
dParams.Add("@SerialNumber", warranty.SerialNumber);

var result = conn.Query<Warranty>("TMP_WARRANTY_INFORMATION_insert", dParams ,commandType: CommandType.StoredProcedure).First();

But then it says "When using the multi-mapping APIs ensure you set the splitOn param if you have keys other than Id", so I try to add a splitOn parameter, but I can't seem to do it according to how the docs/internet says it should, and intellisense can't find the param.

Am I doing something wrong or is it Dapper?

Popular Answer

I got it working. I switched from .Query to .Execute, and changed some of the params

var dParams = new DynamicParameters();

 dParams.Add("@ShipDate", warranty.ShipDate, DbType.String, ParameterDirection.Input);
 dParams.Add("@WarrantyStartDate", warranty.WarrantyStartDate, DbType.String, ParameterDirection.Input);
 dParams.Add("@WarrantyEndDate", warranty.WarrantyEndDate, DbType.String, ParameterDirection.Input);
 dParams.Add("@SerialNumber", warranty.SerialNumber, DbType.String, ParameterDirection.Input);

  var result = conn.Execute("TMP_WARRANTY_INFORMATION_insert", dParams ,commandType: CommandType.StoredProcedure);


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why