加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

在Linq到SQL中使用XQuery?

发布时间:2020-12-12 16:13:32 所属栏目:MsSql教程 来源:网络整理
导读:假设我有一个表,它有一列XML类型的数据.在SQL中,我可以执行以下语句: select top 10 *,Content.value('(/root/item/value)[1]','float') as Valuefrom xmltabletestwhere Content.value('(/root/item/MessageType)[1]','int') = 1 结果集仅包含与条件匹配的
假设我有一个表,它有一列XML类型的数据.在SQL中,我可以执行以下语句:
select   top 10  *,Content.value('(/root/item/value)[1]','float') as Value
from     xmltabletest
where    Content.value('(/root/item/MessageType)[1]','int') = 1

结果集仅包含与条件匹配的记录,并将其从XML中提取为名为“Value”的列.尼斯和简单

Linq To SQL可以实现同样的事情吗?

我想让SQL做大的工作,只返回符合我的标准的数据,而不必选择,传输,然后处理一个潜在的大量数据.据我所知,这是不可能的,但我以为我应该问.

(环境为.NET 3.5,VS2008,SQL Server 2005如果有帮助)

解决方法

我不完全确定这是否已经过时了,但根据 Scott Guthrie XML数据类型是:

represented as strings in LINQ to SQL
Entities. You could use XLINQ to query
on an XML column within your LINQ to
SQL entitiy – but this querying would
happen in your middle-tier (within
ASP.NET). You can’t execute a remote
XQuery against the database and filter
returned results based on that in the
first release.

所以在回答你的问题时,我会说“不”.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读