I have a SqlMetaData array defined as:
SqlMetaData[] _TvpSchema = new SqlMetaData[]{
new SqlMetaData("Duration", SqlDbType.Float)
};
And SqlDataRecord for it as :
SqlDataRecord _DataRecord = new SqlDataRecord(_TvpSchema);
And filling this record as:
_DataRecord.SetFloat(4, (float)obj.Duration);
Where obj.Duration is decimal type and has value as 0. I am getting Exception of Invalid Cast at the above line. I tried Convert.ToSingle also, but got the same error. What I might be doing wrong in this case?