I have a List<> object which I have to pass to a stored procedure in SQL Server 2008 as a table valued parameter. Here is the code:
List<someType> listObjects = new List<someType>();
//Fill listObjects
...
...
...
sqlcmd.Parameters.AddWithValue("@myTableValuedParameter",listObjects).SqlDbType = SqlDbType.Structured;
sqlcmd.ExecuteNonQuery();
Code is throwing an exception which says:
Object must implement IConvertible.
In past,I have successfully passed a DataTable as a table valued parameter.
Structure of type of object someType is same as custom Type which I created in Sql Server.
What am I missing here and what changes do I need to include to make it run sucessfully