title: MVC Return List of Columns Other Than Full Model
body: <p>I have a Model created with a table called "Customers".  </p>
  
  <p>It contains the following fields:</p>
  
  <ul>
  <li>CustomerProfileID</li>
  <li>CustomerName</li>
  <li>BirthDate</li>
  <li>Address1</li>
  <li>City</li>
  <li>State</li>
  <li>Zip</li>
  <li>CreatedOn</li>
  <li>CreatedBy</li>
  </ul>
  
  <p>I did a "Function Import" of a Stored Procedure (CustomerProfiles_Search) that Searches the table.  (I cannot post the Sproc due to sensitive information).  The "Returns a Collection Of" is set to "Entities: CustomerProfile". It returns the following:</p>
  
  <ul>
  <li>CustomerName</li>
  <li>BirthDate</li>
  <li>Address1</li>
  </ul>
  
  <p><strong>Now here is where I get confused.</strong>  I have my Controller that is passing in the fields to search by and then passes it into my "Gateway" which returns a list.  </p>
  
  <p><strong>My Controller:</strong></p>
  
  <pre><code>public ActionResult GetRowCount(string CustomerName, string BirthDate, string Address1, string City, string State, string Zip)
  {
      List&lt;CustomerProfile&gt; searchResults = CustomerProfileGateway.Search(CustomerName, BirthDate, Address1, City, State, Zip);
  
      int count = searchResults.Count();
      string rowCount = count.ToString();
  
      if (Request.IsAjaxRequest())
          return Content(rowCount);
      else
          return RedirectToAction("Index", "OneView");
  }
  </code></pre>
  
  <p>... Inside my <strong>CustomerProfileGateway.cs</strong> file:</p>
  
  <pre><code>public static List&lt;CustomerProfile&gt; Search(string CustomerName, string BirthDate, string Address1, string City, string State, int Zip)
  {
      using (ModelEntities context = new ModelEntities())
      {
          return context.CustomerProfiles_Search(CustomerName, BirthDate, Address1, City, State, Zip).ToList();
      }
  }
  </code></pre>
  
  <p>However, when I try to output the results to a List, I get an error when I do:</p>
  
  <pre><code>The data reader is incompatible with the specified 'SVPModel.CustomerProfile'. A member of the type, 'CustomerProfileID', does not have a corresponding column in the data reader with the same name.
  </code></pre>
  
  <p>I think I need to create a Model of what is returned. </p>
  
  <p><strong>I created the following:</strong></p>
  
  <pre><code>namespace Project.ABC.Objects
  {
      class SearchModel
      {
              public class SearchResults
              {
                  public string CustomerName { get; set; }
                  public string BirthDate { get; set; }
                  public string Address1 { get; set; }
              }
      }
  }
  </code></pre>
  
  <p>But I don't know how to do this?  Can someone please show me what I am doing wrong here.  Any help is greatly appreciated. </p>