title: Return data from stored procedure that contains multiple queries in EF6/MVC5
body: <p>If I have a stored procedure with multiple queries called using different “actions” it seems like EF can’t find all the queries and make a complex type that reflects them.  It looks like it just took the first query it found in the sproc and created the result type to fit that which only includes 3 fields.</p>
  
  <pre><code>@Action VARCHAR(20) = Null,
  @ID INT = Null,
  @Username VARCHAR(50) = Null,
  @Description VARCHAR(200) = Null,
  @Account VARCHAR(20) = NULL,
  @BranchCode SMALLINT = NULL,
  @Receipt BIT = NULL,
  @BackDate DATETIME = NULL,
  @GetDate DATETIME = NULL,
  @AccountID CHAR(16) = NULL,
  @StatementDate DATETIME = NULL
  as
  
  Set @GetDate = Convert(Datetime,Convert(Varchar(10), GetDate(), 101))
  
  IF @Action = 'GetStatements'
  BEGIN
     SELECT DISTINCT [AccountID], [CardHolderName], [StatementDate]
     FROM CorpCardTransactions
     WHERE username = @username + '@xxxxxxxx.com'
     ORDER BY StatementDate
  END
  
  IF @Action = 'EmpSubmitTransactions'
  BEGIN
     UPDATE CorpCardTransactions
     SET [Description] = @Description, [GL_Account] = @Account, BranchCode = @BranchCode, Receipt = @Receipt,
         SubmitDate = @GetDate
     WHERE ID = @ID
  END
  </code></pre>
  
  <p>In my code I’m calling the EmpSubmitTransactions query when the “finishBtn” is clicked.</p>
  
  <pre><code>[HttpPost]
      public  ActionResult Index(List&lt;CorpCardTransaction&gt; list, string saveBtn, string finishBtn)
      {
          if (ModelState.IsValid)
          {
              if (saveBtn != null)
              {
                  using (db)
                  {
                      foreach (var i in list)
                      {
                          var t = db.CorpCardTransactions.Where(a =&gt; a.ID.Equals(i.ID)).FirstOrDefault();
                          if (t != null)
                          {
                              t.Description = i.Description;
                              t.GL_Account = i.GL_Account;
                              t.BranchCode = i.BranchCode;
                              t.Receipt = i.Receipt;
                          }
                      }
                      db.SaveChanges();
                      ViewBag.Message = "Successfully updated.";
                      return View(list);
                  }
              }
              else 
              {
                  using (db)
                  {
                      foreach (var i in list)
                      {
                          db.sp_CorpCardExpense("EmpSubmitTransactions", i.ID, null, i.Description, i.GL_Account, i.BranchCode, i.Receipt, null, null, null, null);
                      }
                      return RedirectToAction("Index", "Statements");
                  }
              }
          }
          else
          {
              ViewBag.Message = "Ooops, something is wrong with the Model State.  Try again.";
              return View(list);
          }
      }
  }
  </code></pre>
  
  <p>When I click the finishBtn, it does get to the right part of the code and it does try and fire off the stored procedure, but it gives me this error, </p>
  
  <p>“The data reader is incompatible with the specified 'CorpCardTransactionsModel.sp_CorpCardExpense_Result'. A member of the type, 'AccountID', does not have a corresponding column in the data reader with the same name.”</p>
  
  <p>I’m not trying to return all the fields, I’m just trying to send them all to the sproc plus let the sproc do some other things like mark the fields as “finished” then redirect me to the list of statements again.  I’m only updating the table, not returning any fields, and trying to redirect so I guess I don’t understand why it can’t find “AccountID”.    Why is it referring to a data reader?  </p>