我试图将表值参数传递给存储过程,但我不断得到一个异常(见下文).
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();Run Code Online (Sandbox Code Playgroud)
类型在服务器上定义如下:
CREATE TYPE [dbo].[IdList] AS TABLE(
[Id] [int] NOT NULL
)Run Code Online (Sandbox Code Playgroud)
我试图通过sharedPdfs为List<int>,和IQueryable<int>,但不断收到以下异常:
Object must implement IConvertible.
谁知道我做错了什么?文档暗示我应该能够将列表作为TVP传递但不提供任何示例.
谢谢.