A
Aleksei
SqlParameter converts the value to a CLR type. But this is a problem
while storing OUTPUT parameter values to CLR variable of a type from
System.Data.SqlTypes namespace. For example, the following obviously
does not work
SqlParameter p = new SqlParameter ("@id",SqlDbType.UniqueIdentifier);
SqlGuid id = (SqlGuid) p.Value;
Replacing the second line helps
SqlGuid id;
if (p.Value is DBNull) id=SqlGuid.Null;
else id.Value=(Guid) p.Value;
But this solution implies two conversions and the performance gain
(noted in MSDN library, "System.Data.SqlTypes") could not be achieved.
Using CLR type System.Guid instead of System.Data.SqlTypes.SqlGuid
denies accepting DBNull values.
Is there any way to get SqlType from a SqlParameter directly? Maybe I
have missed something?
Aleksei
while storing OUTPUT parameter values to CLR variable of a type from
System.Data.SqlTypes namespace. For example, the following obviously
does not work
SqlParameter p = new SqlParameter ("@id",SqlDbType.UniqueIdentifier);
SqlGuid id = (SqlGuid) p.Value;
Replacing the second line helps
SqlGuid id;
if (p.Value is DBNull) id=SqlGuid.Null;
else id.Value=(Guid) p.Value;
But this solution implies two conversions and the performance gain
(noted in MSDN library, "System.Data.SqlTypes") could not be achieved.
Using CLR type System.Guid instead of System.Data.SqlTypes.SqlGuid
denies accepting DBNull values.
Is there any way to get SqlType from a SqlParameter directly? Maybe I
have missed something?
Aleksei