I'm trying to use Dapper to call a stored procedure that has a couple Output parameters, using VB.NET (and .NET 4.0).
However, it seems I cannot use the
DynamicParameters.Add method, because I'm getting the following compiler error:
'Add' is ambiguous because multiple kinds of members with this name exist in class 'Dapper.DynamicParameters'.
...when I try to write the following line:
p.Add("@NewRecordID", DbType:=DbType.Int32, direction:=ParameterDirection.Output)
A quick search tells me this sometimes happens when using a C# library that has multiple methods that differ only in name case (VB.NET being case-insensitive). Searching the Dapper source code for
DynamicParameters does show the following two overloads for the
Add method, but they both use the same case, and the compiler should be able to discern between the two.
public void Add(string name, object value, DbType? dbType, ParameterDirection? direction, int? size) public void Add(string name, object value = null, DbType? dbType = null, ParameterDirection? direction = null, int? size = null, byte? precision = null, byte? scale = null)
(I've also tried adding
scale:=Nothing to the call to force the second overload, to no avail.)
While I can work around this with the input parameters by passing in an anonymous object to the
DynamicParameters constructor, I can't find a way around this when adding the output parameters.
I've checked the project references to ensure there aren't multiple or ambiguous assembly references.
Has anybody encountered this problem before, and found a workaround?
At the moment, the only option I can think of is to re-write the stored procedure call without using Dapper, as implied here.
From what I can gather, the following are all potential solutions: