System.InvalidCastException: Failed to convert parameter value from a String to a IEnumerable`1.
—> System.InvalidCastException: Invalid cast from ‘System.String’ to ‘System.Collections.Generic.IEnumerable`1
[[System.Data.Common.DbDataRecord, System.Data, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b77a5c561934e089]]’.
at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType, Boolean& coercedToDataFeed, Boolean& typeChanged, Boolean allowStreaming)
— End of inner exception stack trace —
We use SQL User-Defined-Types to pass XML data from BizTalk to SQL stored procs.
I had to build a custom EDI schema to change the inbound validation for a field.
In this particular project, the EDI pipeline had “Preserve Interchange” set to true.
I knew there was a map in my project on this data, but the map itself used a special little schema that supported the “Preserve Interchange” format.
So I think I might get lucky, and just be able to deploy the schema.
Well – the map used XSLT, and the XSLT had the namespace of the schema.
So although the map ran, it was generating a call to the stored proc that had no data, i.e. the User-Defined-Type didn’t get mapped under the root element.
That caused the odd validation error above!
In Summary – the namespace in the XSLT did not match the namespace specified in the Party/Agreement configuration. Thus the output of the map had a root element, but none of the User-Defined-Type elements.