views:

477

answers:

2

I have asked this question before. but i was not able to get any answer. may be i wasnt very clear. let me give some more details.

I have a SP which returns a long string. here is dbml file code

[Function(Name="dbo.spX")]
public ISingleResult<spXResult> spX([Parameter(DbType="VarChar(8000)")] string str)
{
    IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), str);
    return ((ISingleResult<spXResult>)(result.ReturnValue));
}

and here is spXResult class

public partial class spXResult
{
    private string _XML_F52E2B61_18A1_11d1_B105_00805F49916B;

    public spXResult()
    {  }

    [Column(Name="[XML_F52E2B61-18A1-11d1-B105-00805F49916B]", 
     Storage="_XML_F52E2B61_18A1_11d1_B105_00805F49916B", 
     DbType="NText", UpdateCheck=UpdateCheck.Never)]
    public string XML_F52E2B61_18A1_11d1_B105_00805F49916B
    {
        get
        {
            return this._XML_F52E2B61_18A1_11d1_B105_00805F49916B;
        }
        set
        {
            if ((this._XML_F52E2B61_18A1_11d1_B105_00805F49916B != value))
            {
                this._XML_F52E2B61_18A1_11d1_B105_00805F49916B = value;
            }
         }
     }
}

and here is my code

ISingleResult<spXResult> result = ctx.spX("1234");

string returnStr = result.First().XML_F52E2B61_18A1_11d1_B105_00805F49916B;

everything is fine, when the result is not a long string, but as soon as the sp returns a very long string, it truncates the result. i have no clue why.. can someone please help.

thanks

+1  A: 

The only thing fishy I can spot is this - here in the declaration, you hvae:

public ISingleResult<spXResult> spX([Parameter(DbType="VarChar(8000)")] string str)

(DbType=VARCHAR(8000)) - which is ANSI (non-Unicode), but then in the column declaration you use NTEXT - first of all, that's UNICODE (2-byte per character), and why NTEXT?? Above you have VARCHAR?

[Column(Name="[XML_F52E2B61-18A1-11d1-B105-00805F49916B]", 
     Storage="_XML_F52E2B61_18A1_11d1_B105_00805F49916B", 
     DbType="NText", UpdateCheck=UpdateCheck.Never)]

That seems a bit odd.......

Can you try to make it the same in both places? E.g. VARCHAR(8000) in both cases??

Marc

marc_s
I tried that too .actually i modified the method to return IMULtipleResults and look thru to get the rest of the string.. the behavior is weird. may be somehthing is limitng the return string length
jyotishka bora
loop thru i mean
jyotishka bora
Can you check in the DB how long those strings are?? SELECT (string), DATALENGTH(string) FROM (table) - and see if any are indeed more than 8000 characters??
marc_s
A: 

Just change your sp from

SELECT ...
  FROM MyTable
  FOR XML AUTO

to

DECLARE @ResultXML xml

SET @ResultXML = 
 (SELECT ...
  FROM MyTable
  FOR XML AUTO)

SELECT @ResultXML as [MyXML]

and recreate linq method