I am using the following code to set up parameters for a call to a stored procedure:
List<SqlParameter>parameterList = new List<SqlParameter>();
parameterList.Add(new SqlParameter("@Title", adminTest.Title));
parameterList.Add(new SqlParameter("@Text", adminTest.Text));
var questionsList = new SqlParameter("@Questions", questions);
questionsList.TypeName = "dbo.QuestionList";
parameterList.Add(questionsList);
The code snippet works but what I would like to know is if anyone found a way to set the TypeName in the new SqlParameter constructor? I tried looking at the documentation but the only thing I can find is adding the typename afterwards.
Anonymous User
21-Nov-2014You can accomplish this with initializers. The example below specifies strongly-typed parameters and max length of variable values, which is a good practice from a SQL performance perspective.