I have a stored procedure which uses a FOR XML statement at the end of it, and returns me some XML.
I am using .NET 4 and the Entity Framework and when I do a functi
I upvoted Fermin's answer. Response to Dementic (and anyone else), here is a code fragment.
From this:
using (var db = new MyEntities())
{
IEnumerable<string> results = db.GetSomeXML(ProductCode);
return results.FirstOrDefault();
}
To this:
using System.Text; //For the StringBuilder
using (var db = new MyEntities())
{
StringBuilder retval = new StringBuilder();
IEnumerable<string> results = db.GetSomeXML(ProductCode);
foreach (var result in results)
retval.Append(result);
return retval.ToString();
}
I ran into the same issue today.
The EF function call returns the XML in 2033-long string 'chunks' (e.g. if your XML was 5000 chars long you would receive 3 results: 2 of 2033 chars and 1 of 934 chars)
You can easily append these chunks to return a full list of the XML.