Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Linq, xml, and 2033 characters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
R Dorris - 28 Feb 2008 00:30 GMT
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
returning a class that has one property of type string. When my code calls
the sp, I'm only getting back the first 2033 characters of the xml.... that's
no good. I've tried changing the return class to have a property of type
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.
Jon Skeet [C# MVP] - 28 Feb 2008 00:41 GMT
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.