Can I get around "There are multiple root elements"?
I'm working with a database that I have no control over, one column is an XML type, and it contains, yep, multiple root elements. So my LINQ throws an exception.
I understand the error and why, but开发者_开发问答 I can't control the data. I'd rather not tweak any auto-generated code.
Is there any way to get around this exception?
You can use a subselect to add a root element younr xml-string:
select concat("<mynewroot>",mxmlcolumn,"</mynewroot>") from
(select * from mytable);
I know this is sql syntax and no linq-syntax but this should also be possible in linq, I hoep you get the idea.
An other way would be to not let linq interpret the xml column as xml but as string, or let it interpret the xml just as xml-fragment.
精彩评论