I have simple code to create a SqlParameter for Table Valued Type. This code works fine with .NET 4.0. The problem with MONO CS (3.12.0), I can’t just compile the same code in MONO.
static SqlParameter GetDataTableParam(string _tableName, DataTable _dt)
{
SqlParameter tValue = new SqlParameter();
tValue.ParameterName = "@dr" + _tableName;
tValue.SqlDbType = SqlDbType.Structured;
tValue.Value = _dt;
tValue.TypeName = string.Format("dbo.{0}Item", _tableName);
return tValue;
}
Mono compiler giving me this error:
Error CS1061: Type `System.Data.SqlClient.SqlParameter' does not contain a definition for `TypeName' and no extension method `TypeName' of type `System.Data.SqlClient.SqlParameter' could be found. Are you missing an assembly reference? (CS1061)
This code simply tries to create a parameter for the TableValued Type and pass the data table to the SQL insert statement.
I know that the error can be resolved if I use a stored procedure, but in my case it is not possible to create a merge SP insert for each table.
So please help me if there is any work around this issue.
. , MONO System.Data.SqlClient.SqlParameter TypeName. , , :
The table type parameter '@drFactory' must have a valid type name.