When passing an xml string through dapper to SQL Server 2008, dapper seems to be creating a parameter for each one of characters in the xml string.
For example, if the string is <outer></outer>
it appears to be creating a parameter
for each character ( '<', 'o', 'u', 't', etc..)
In old version the code would pass one parameter (namely the xml parameter that was specified) into the stored procedure.
Set up code looks like the following -
var xml = @"
<OuterElement>
<InnerElement>1</InnerElement>
<InnerElement>2</InnerElement>
<InnerElement>3</InnerElement>
<InnerElement>4</InnerElement>
</OuterElement>";
var parameters = new Dapper.DynamicParameters();
parameters.Add("@XmlParameter", xml, DbType.Xml);
SqlMapper.Query(
connection,
"dbo.TestXmlInput",
parameters,
commandType: CommandType.StoredProcedure,
commandTimeout: 60
);
My questions are as follows: Can anyone else reproduce this? If so, Was this change intentional or a bug? Is there a workaround for achieving xml parameter passing?
The generated SQL looks like this:
exec dbo.TestXmlInput (@XmlParameter1, @XmlParameter2, @XmlParameter3, ...)
Any help would be greatly appreciated.