title: Can't get the return of this stored procedure in Entity Framework
body: <p>I don't know why this time it doesn't work, I already did this a couple of times but this one is giving me trouble.</p>
  
  <p>This is my C# code :</p>
  
  <pre><code>RT_TYPE_STRING query = dba.Database.SqlQuery&lt;RT_TYPE_STRING&gt;("EXEC dbo.CSDN_CreateDemandeAppro @sp1, @sp2, @sp3, @sp4", new SqlParameter("sp1", "20162017"), new SqlParameter("sp2", "590"), new SqlParameter("sp3", "430614451421"), new SqlParameter("sp4", 22.18m)).First();
  
  if (query.NO_DA == "")
  {
  }
  </code></pre>
  
  <p>And somehow, query is null. I tried executing the stored procedure directly in Management Studio and it returned a <code>nvarchar</code> properly.</p>
  
  <p>This is my RT_TYPE_STRING</p>
  
  <pre><code>CREATE TABLE [dbo].[RT_TYPE_STRING]
  (
      [NO_DA] [nvarchar](8) NOT NULL,
  
      CONSTRAINT [PK_RT_TYPE_STRING] 
          PRIMARY KEY CLUSTERED ([NO_DA] ASC)
                  WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, 
                        IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, 
                        ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  ) ON [PRIMARY]
  </code></pre>
  
  <p>And this is my stored procedure, in case you want to look at it:</p>
  
  <pre><code>SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  
  ALTER PROCEDURE [dbo].[CSDN_CreateDemandeAppro]
      @EXER_FIN   nvarchar(8),
      @UNIT_ADM   nvarchar(6),
      @NOM_CONT   nvarchar(30),
      @MNT_TOTAL  numeric(15, 2)
  AS
      DECLARE
              @NO_DA  nvarchar(8),
              @TYPE   nchar(1),
              @STAT   nchar(1),
              @ETAT   nchar(1),
              @IND_ENG    nchar(1),
              @IND_APPR   nchar(1),
              @TYPE_TRAIT nchar(1),
              @TEL    nvarchar(11),
              @POSTE  nvarchar(5),
              @NOM_ACHET  nvarchar(30),
              @COMMENT_ACHET  nvarchar(255),
              @DATE_CREAT smalldatetime,
              @DATE_MAJ   smalldatetime,
              @DATE_APPR  smalldatetime,
              @CODE_FOND  tinyint,
              @NO_COMM_DOFIN  nvarchar(9),
              @NO_MAG nvarchar(6),
              @NO_SEQ int,
              @NO_DA_OUT int
  
      BEGIN TRAN
          SELECT @NO_DA = PROC_NO_DA FROM ACH_UNIT_ADM_NUM WHERE UNIT_ADM = @UNIT_ADM and EXER_FIN = @EXER_FIN ;
          UPDATE ACH_UNIT_ADM_NUM SET PROC_NO_DA = @NO_DA + 1 WHERE UNIT_ADM = @UNIT_ADM and EXER_FIN = @EXER_FIN ;
      COMMIT;
  
      SET @TYPE = '0';
      SET @STAT = '3';
      SET @ETAT = 'C';
      SET @IND_ENG = '0';
      SET @IND_APPR = '0';
      SET @TYPE_TRAIT = '1';
      SET @TEL = NULL;
      SET @POSTE = NULL;
      SET @NOM_ACHET = NULL;
      SET @COMMENT_ACHET = 'APPROVISIONNEMENT.CSDN.QC.CA';
      SET @DATE_CREAT = GETDATE();
      SET @DATE_MAJ = GETDATE();
      SET @DATE_APPR = NULL;
      SET @CODE_FOND = '1';
      SET @NO_COMM_DOFIN = NULL;
      SET @NO_MAG = NULL;
      SET @NO_SEQ = 1;
      SET @NO_DA_OUT = 0;
  
  
  
  
  
      INSERT INTO DBO.ACH_DA 
      VALUES (
          @EXER_FIN,
          @NO_DA,
          @UNIT_ADM,
          @TYPE,
          @STAT,
          @ETAT,
          @IND_ENG,
          @IND_APPR,
          @TYPE_TRAIT,
          @NOM_CONT,
          @TEL,
          @POSTE,
          @NOM_ACHET,
          @COMMENT_ACHET,
          @DATE_CREAT,
          @DATE_MAJ,
          @DATE_APPR,
          @MNT_TOTAL,
          @NO_SEQ,
          @CODE_FOND,
          @NO_COMM_DOFIN,
          @NO_MAG);
  
      Select @NO_DA;
  </code></pre>
  
  <p>SSMS trace :</p>
  
  <pre><code>exec sp_executesql N'EXEC dbo.CSDN_CreateDemandeAppro @sp1, @sp2, @sp3, @sp4',N'@sp1 nvarchar(8),@sp2 nvarchar(3),@sp3 nvarchar(12),@sp4 decimal(4,2)',@sp1=N'20162017',@sp2=N'590',@sp3=N'430614451421',@sp4=22.18
  </code></pre>