views:

61

answers:

0

I'm pretty new to Linq to SQL & Linq to XML but have cobbled together some code together that put the XML results from a stored proc into an XElement. However, it's started failing, apparently now that the XML data is getting larger (2K+) and my .Parse is reading truncated XML (the XML data comes back in two rows). Before i start fumbling into the weeds using xmlReaders and all that, maybe i'm looking at this wrong and there are better approaches.

My exact problem is below, but i'm also curious about any standard Linq idioms for doing this type of thing.


The specific error i'm getting is

System.Xml.XmlException: Unexpected end of file while parsing Name has occurred. Line 1, position 2034.

My C# code is something like this

XDocument orders = new XDocument(from b in db.GetUserOrders(userid)
 select XElement.Parse(b.XML_F52E5B62_58B1_21e2_B105_00805A49AB12));

The stored proc looks like

select * from orders where userid = @userid order by tscreated
for xml raw('order'), ROOT('orders')

The XML returned from the stored proc looks like

<orders>
  <order OrderId="123" UserId="bob" tscreated="2010-07-16T16:46:46.173">
    <morexml>
      <element1>
        <element2>abc</element2>
        <!--more stuff-->
      </element1>
    </morexml>
  </order>
  <!--lots more orders-->
</orders>