带有存储过程和用户​​定义表类型参数的 LINQ to SQL [英] LINQ to SQL with stored procedures and user defined table type parameter

查看:26
本文介绍了带有存储过程和用户​​定义表类型参数的 LINQ to SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 LINQ to SQL 与 SQL Server 2008 中的存储过程一起使用.除了一个问题外,一切都运行良好.L2S 无法为以用户定义的表类型作为参数的存储过程生成方法.dbml 设计面板中的方法签名使用对象作为参数类型而不是表类型,当我尝试编译时出现错误:

I am using LINQ to SQL with stored procedures in SQL Server 2008. Everything work well except one problem. L2S cannot generate the method for the stored procedure with user defined table type as parameter. Method signature in dbml design panel use object for parameter type instead of table type and when I tried to compile I got error:

Error: DBML1005: Mapping between DbType 'Structured' and
Type 'System.Object' in Parameter 'ParaName' of Function 'dbo.StoredProcName'
is not supported. 

有没有办法解决这个问题?我不想回到传统的 ADO.NET 数据访问.

Is there a way to work around this of this problem? I don't want to go back to traditional ADO.NET data access.

推荐答案

我认为现在没有任何可用的东西 - SQL Server 2008 中引入了表值参数 - 在 LINQ 和 LINQ2SQL 已经推出之后.

I don't think there's anything available right now - table-valued parameters were introduced in SQL Server 2008 - after LINQ and LINQ2SQL were out already.

到目前为止,我在任何博客文章中都没有提到在 .NET 4.0 中支持 LINQ2SQL 中的表值参数.

I haven't found any mention in any of the blog post about support for table-valued parameters in LINQ2SQL in .NET 4.0 so far.

更新:
这是Damien Guard 的博文 关于 .NET 4.0 时间范围内对 Linq-to-SQL 的修复和改进.

UPDATE:
Here's a blog post by Damien Guard on the fixes and improvement for Linq-to-SQL in the .NET 4.0 time frame.

更新 2:
不幸的是,根据 Damien 的说法,.NET 3.5 不支持此功能,.NET 4.0 也不支持此功能:-(

UPDATE 2:
Unfortunately, according to Damien, this feature isn't supported in .NET 3.5, and will not be supported in .NET 4.0 either :-(

目前无法在 3.5 或 4.0 中完成
:( [)amien

这篇关于带有存储过程和用户​​定义表类型参数的 LINQ to SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆