Skip to content Skip to sidebar Skip to footer

How Should I Pass A User-defined Type To Sqlparametercollection.addwithvalue?

I have a custom data type called StudentID, which has an implicit conversion to string. When I pass a StudentID instance to SqlCommand.Parameters.AddWithValue (as the value) and ex

Solution 1:

As I know you can't pass UDTs. Only primitive or Sql* types are allowed.

Solution 2:

It seems you can use SqlUserDefinedTypeAttribute with your custom type. Take a look at the current implementation of GetMetaTypeFromValue.

Post a Comment for "How Should I Pass A User-defined Type To Sqlparametercollection.addwithvalue?"