Home
Options

Stored Procedure working in LP5, but not LP6.

edited July 2020

I have a stored procedure that accepts an XElement as an input parameter and returns a pretty standard DataSet. I have it working in LinqPad5, and a Visual Studio .NET Core application, but in LP6, the stored procedure returns a NullReferenceException. Intellisense resolves it until run time, then NRE.

I've tried working straight out of the box with System.Data.SqlClient and I've tried with Microsoft.Data.SqlClient. From the NRE message it looks like linqpad is only attempting to use the System.Data.SqlClient.

Comments

  • Options

    Looks like an issue in .NET Core. You could use the following code for SQL server, derived from the decompiled version (F12 / goto ExecuteStoredProcedure in ILSpy).

    //ExecuteCommand("CREATE PROC pGetEmailMessagePathInformation ( @xml XML ) AS SELECT 1 AS Result");
    
    var doc = XElement.Parse(
      @"<messages>
          <message
            MessageId=""123456""
            MessageDate=""01/08/2001 13:10:00:000""
            ContentTypeId=""1"" />
        </messages>");
    
    doc.Dump();
    
    Connection.Open();
    
    using var cmd =
      new SqlCommand("pGetEmailMessagePathInformation", Connection as SqlConnection)
      {
        CommandType = CommandType.StoredProcedure,
        CommandTimeout = CommandTimeout
      };
    
    cmd.Parameters.Add(new SqlParameter("@xml", doc.ToString()));
    
    using var da = new SqlDataAdapter(cmd as SqlCommand);
    
    using var ds = new ReturnDataSet();
    
    da.Fill(ds);
    
    ds.Dump();
    
Sign In or Register to comment.