title: How to use stored procedure in jqgid?
body: <p>I want to use stored procedure to fill my JqGrid. My stored procedure is below:</p>
  
  <pre><code>ALTER  PROCEDURE [dbo].[SubJqGridObisDataSP]
  as begin
  DECLARE @header AS NVARCHAR(MAX),@MetID AS bigint 
  SELECT @header = 
  STUFF((SELECT ',' + QUOTENAME([ObisInfoTranslateT]) 
  
       from MetContDB.dbo.tblMet AS met
       join MetContDB.dbo.tblMod AS mod on mod.ModID= met.ModID_FK  
       join MetContDB.dbo.tblGroupData As Gro on Gro.MetID_FK= met.MetID
       join MetContDB.dbo.tblObisData as obisdata on     obisdata.GroupDataID_FK=Gro.GroupDataID
       join MetContDB.dbo.tblObisInfo AS obisinfo on obisinfo.ObisInfoID=obisdata.ObisInfoID_FK
       join (select  max(GroupDataID) as maxgroupdata   from MetContDB.dbo.tblGroupData   where MetID_FK=@MetID) g on Gro.GroupDataID=g.maxgroupdata 
       where met.MetID=@MetID
  
          FOR XML PATH(''), TYPE
          ).value('.', 'NVARCHAR(MAX)') 
      ,1,1,'')
  DECLARE @DynamicPIVOT AS NVARCHAR(MAX) 
  SELECT @DynamicPIVOT = 'SELECT ' + @header +
  ' FROM (
  select 
  obisdata.ObisData,
         obisinfo.[ObisInfoTranslateT]
  
        from MetContDB.dbo.tblMet AS met
       join MetContDB.dbo.tblMod AS mod on mod.ModID= met.ModID_FK  
       join MeterControlDB.dbo.tblGroupData As Gro on Gro.MetID_FK= met.MetID
       join MetContDB.dbo.tblObisData as obisdata on obisdata.GroupDataID_FK=Gro.GroupDataID
       join MetContDB.dbo.tblObisInfo AS obisinfo on obisinfo.ObisInfoID=obisdata.ObisInfoID_FK
       join(select 
             max(GroupDataID) as maxgroupdata
             from MeterControlDB.dbo.tblGroupData
          where MetID_FK=@MetID) g on Gro.GroupDataID=g.maxgroupdata 
          where met.MetID=@MetID) Books
  PIVOT (MAX(ObisData) FOR [ObisInfoTranslateT] IN (' + @header + ')) Result;'
  
  EXEC (@DynamicPIVOT)
  end
  </code></pre>
  
  <p>But when i use this SP in my controller, I get error : output of Stored procedure is int?????
  My output stored procedure is some row. controller:</p>
  
  <pre><code>MetContDBEntities ctnx = new MetContDBEntities();
  var obisDatas = ctnx.SubJqGridObisDataSP(id).ToList();
  </code></pre>
  
  <p>my code before query is:</p>
  
  <pre><code>select obisdata.ObisData,obisinfo.ObisInfoTranslateT
        from MetContDB.dbo.tblMet AS met
       join MetContDB.dbo.tblMod AS mod on mod.ModID= met.ModID_FK  
       join MetContDB.dbo.tblGroupData As Gro on Gro.MetID_FK= met.MetID
       join MetContDB.dbo.tblObisData as obisdata on obisdata.GroupDataID_FK=Gro.GroupDataID
       join MetContDB.dbo.tblObisInfo AS obisinfo on obisinfo.ObisInfoID=obisdata.ObisInfoID_FK
       join(select 
             max(GroupDataID) as maxgroupdata
             from MetContDB.dbo.tblGroupData
          where MetID_FK=39) g on Gro.GroupDataID=g.maxgroupdata 
          where met.MetID=39
  </code></pre>
  
  <p>Output of this:
  <img src="https://i.stack.imgur.com/LnpeA.png" alt="enter image description here">
  I want to show like this:
  <img src="https://i.stack.imgur.com/KZqwn.png" alt="enter image description here"></p>
  
  <p>With first query I can change pic1 to pic2 .</p>