> I have a sp in sql2005 that uses the for xml path statement that I'm trying
> to call using Linq to Sql. I've setup the sp in the datacontext and have it
[quoted text clipped - 3 lines]
> XDocument, but that fails too because the returned xml only has the first
> 2033 characters and therefore is not a valid xml document. Any ideas? thanks.
See http://aspnetresources.com/blog/executescalar_truncates_xml.aspx
It doesn't solve the LINQ aspect, but it might explain a bit about why
it's happening.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
R Dorris - 28 Feb 2008 00:51 GMT
So it looks like looping/concatenating the results will fix my problem. I
guess I could then parse the string into an XDocument and make this whole
thing a method in my partial class for the return class. BUT, is there a
better way? If I want xml from the sql server, is there a better way to
retrieve it than using Linq to Sql? thanks for the help.
> > I have a sp in sql2005 that uses the for xml path statement that I'm trying
> > to call using Linq to Sql. I've setup the sp in the datacontext and have it
[quoted text clipped - 8 lines]
> It doesn't solve the LINQ aspect, but it might explain a bit about why
> it's happening.
Peter Duniho - 28 Feb 2008 00:56 GMT
>> I have a sp in sql2005 that uses the for xml path statement that I'm
>> trying
[quoted text clipped - 6 lines]
> It doesn't solve the LINQ aspect, but it might explain a bit about why
> it's happening.
Actually, looking in the comments reveals a solution that doesn't require
explicitly building a new string by looping with ExecuteXmlReader.
Instead, it uses a stored procedure that stores the XML result in an
intermediate SQL XML variable, and returns that instead.
See
http://aspnetresources.com/blog/executescalar_truncates_xml.aspx#cmt1715
(the 12th comment)
So maybe using that approach would allow it to work more smoothly with
LINQ.
Or maybe all of this is over my head, and it doesn't help at all. I'm not
really sure. :)
Pete