将LinqToSQL结果转换为xml [英] convert LinqToSQL result to xml

查看:66
本文介绍了将LinqToSQL结果转换为xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的L2S结果转换为XML

这是我的代码

I want to convert my L2S result into XML

here is my code

Dim linq_result = From c in db.customers select c

dim xml1 as New XElement("customers",from xc in linq_result Select xc )

dim xml2 as New XElement("customers",from xc in linq_result Select xc.field1,xc.field2 )

xml1.Save(c:\folder\xml1.xml)

xml2.Save(c:\folder\xml2.xml)



xml1结果无效

xml2结果有效,因为我明确选择了字段

假设我有25个字段,我应该全部写出来吗?是否有*,例如sql server?

谢谢



xml1 result is not valid

xml2 result is valid because I explicitly chose the fields

let say I have 25 fields, should I write them all ? is there * such as sql server?

Thanks

推荐答案

在这里查看如何使用 LINQ到XML [ ^ ]

在method1中,您尝试选择一个客户对象.使用method2可以选择客户对象的特定属性.没有全部,您必须选择所需的每个属性.
See here for how to work with LINQ to XML[^]

In method1 you attempting to select a customers object. With method2 you are selecting specific properties of the customers object. There is no all, you must select each property you want.


这篇关于将LinqToSQL结果转换为xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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