Click here to Skip to main content
16,012,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 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
Posted

1 solution

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.
 
Share this answer
 
v2
Comments
Sam Martini 5-Nov-11 4:43am    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900