title: Stored Procedure return values with linq data context
body: <p>I am trying to access the return value of a stored procedure with Linq </p>
  
  <pre><code>DECLARE @ValidToken int = 0 //I have also tried using a bit instead of an int here.
  
  IF EXISTS(SELECT 1 FROM Tests WHERE TestToken = @Token)
      select @ValidToken = 1
  
  return @ValidToken
  </code></pre>
  
  <p>This works when running the SP through sql studio. However I am trying to run it with linq using the datacontext class and it is always returning -1.</p>
  
  <pre><code>using (DataEntities dataEntities = new DataEntities())
      {
          int query = data.ValidateToken(id);
          Response.Write(query.ToString());
      }
  </code></pre>
  
  <p>query will always equal -1 and I am not sure why.</p>
  
  <p>I have looked online and it would appear that there are easier ways to get the return value however I would rather stick to Linq as that is what the rest of the program is using.</p>