如何通过EntLib 5.0将表值参数传递给SQL Server 2008?
如何通过EntLib 5.0将表值参数传递给SQL Server 2008?
祝你好运... http://msdn.microsoft.com/zh-cn/library/bb675163.aspx 引用:
Limitations of Table-Valued Parameters
There are several limitations to table-valued parameters:
You cannot pass table-valued parameters to CLR user-defined functions. Table-valued parameters can only be indexed to support UNIQUE or PRIMARY KEY constraints. SQL Server does not maintain statistics on table-valued parameters. Table-valued parameters are read-only in Transact-SQL code. You cannot update the column values in the rows of a table-valued parameter and you cannot insert or delete rows. To modify the data that is passed to a stored procedure or parameterized statement in table-valued parameter, you must insert the data into a temporary table or into a table variable. You cannot use ALTER TABLE statements to modify the design of table-valued parameters.
我没有尝试过这样做,但是快速查看了EntLib数据块后,我没有发现一个简单的方法来实现这个。你可以使用SqlClient对象来完成,但是EntLib不支持你需要传递数据作为TVP的结构化数据类型。
如果你保证永远不需要除了SQL Server后端之外的任何东西,那么我想你可以将连接转换为特定于SQLServer的连接,然后使用SqlParameters,但这有点违背了使用EntLib的目的。