title: Get return value from stored procedure - LINQ
body: <p>I want to get the return value in stored procedure using LINQ, EF. I have seen solutions with T-SQL but that method does not solve the problem. I need to solve it with LINQ.</p>
  
  <p>Return 0 I want to take 1 and -1 according to the result</p>
  
  <p>Stored procedure:</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[Login]
      @inTcNu CHAR(11),
      @inPass NVARCHAR(MAX),
      @inIP NVARCHAR(40),
      @rolNu TINYINT OUTPUT,
      @kulNu INT OUTPUT
  AS
  BEGIN
      SELECT @kulNu = kullaniciID, @rolNu = rolID 
      FROM Kullanici WITH(NOLOCK) 
      WHERE tcNumarasi = @inTcNu AND parola = @inPass;
  
      IF @rolNu &gt;= 0 AND @kulNu &gt;= 0
      BEGIN
          INSERT INTO Oturum (tcNumarasi, oturumIP, parola, oturumZamani, girisBasarili)
          VALUES (@inTcNu, @inIP, @inPass, GETDATE(), 1);
  
          RETURN 1;
      END
      ELSE
      BEGIN
          INSERT INTO Oturum (tcNumarasi, oturumIP, parola, oturumZamani, girisBasarili)
          VALUES (@inTcNu, @inIP, @inPass, GETDATE(), 0);
  
          RETURN 0;
      END
  
      RETURN -1;
  END
  </code></pre>
  
  <p>C#, LINQ, EF</p>
  
  <pre><code>using (var ctx = new ktdbEntities())
  {
      var IP = networkUtils.GetIP();
      var rolNu = new ObjectParameter("rolNu", typeof(int));
      var kulNu = new ObjectParameter("kulNu", typeof(int));
  
      var output = ctx.Login(model.tcNumarasi, model.parola, IP, rolNu, kulNu);
  
      object value1 = rolNu.Value;
      object value2 = kulNu.Value;
  }
  </code></pre>