title: How to pass a table-value parameter
body: <p>I am trying to pass a table-value parameter to a stored procedure, but I keep getting an exception (see below).</p>
  
  <pre><code>SqlCommand c = new SqlCommand("getPermittedUsers", myConn) { CommandType = CommandType.StoredProcedure };
  
  c.Parameters.AddWithValue("@intNotifyingUserId", notifyingUserId);
  c.Parameters.AddWithValue("@tSelectedPdfIds", sharedPdfs).SqlDbType = SqlDbType.Structured;
  
  SqlDataReader dr = c.ExecuteReader();</code></pre>
  
  <p>The type is defined on the server like this:</p>
  
  <pre><code>CREATE TYPE [dbo].[IdList] AS TABLE(
      [Id] [int] NOT NULL
  )</code></pre>
  
  <p>I have tried passing sharedPdfs as a <code>List&lt;int&gt;</code>, and <code>IQueryable&lt;int&gt;</code>, but keep getting the following exception:</p>
  
  <p><code>Object must implement IConvertible.</code></p>
  
  <p>Anyone know what I am doing wrong? The documentation implies that I should be able to pass a list as a TVP but doesn't give any examples.</p>
  
  <p>Thank you.</p>