Entity framework calling a FOR XML stored procedure truncates at 2033 characters

前端 未结 2 519
暗喜
暗喜 2020-12-17 19:44

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

2条回答
  •  悲哀的现实
    2020-12-17 20:24

    I upvoted Fermin's answer. Response to Dementic (and anyone else), here is a code fragment.

    From this:

    using (var db = new MyEntities())
    {
        IEnumerable 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 results = db.GetSomeXML(ProductCode);
        foreach (var result in results)
            retval.Append(result);
    
        return retval.ToString();           
    }
    

提交回复
热议问题