title: Entity Framework query SPA
body: <p>I am new to both SPA and Entity Framework and I have a question about the right/preferred way to do this.</p>
  
  <p>I've got a web page to search customers by some filters (like name, surname, birthday date, phone number).</p>
  
  <p>With ajax I pass from View to Controller a ViewModel object like this:</p>
  
  <pre><code>public class CustomerSearch
  {
      public string Name { get; set; }
      public string Surname { get; set; }
      public DateTime? Birthday{ get; set; }
      public string Phone{ get; set; }
  }
  </code></pre>
  
  <p>Into controller I've got this search method:</p>
  
  <pre><code> public List&lt;CustomerList&gt; GetCustomersList(CustomerSearch cs)
      { ..... }
  </code></pre>
  
  <p>In my application there are also DataAccess objects.</p>
  
  <p>Now, the question is: how I can to do the query to database in smart mode?</p>
  
  <p>I've thinked some scenario but i don't know which is the best about the layer separation.</p>
  
  <ol>
  <li>I can ask to model an IQueryable object and perform the Where condition into controller</li>
  <li>I can create a DataAccess method with the filters like parameters </li>
  <li>I can create a Customer object (model object) filled with the filters value and pass this to model that perform the query </li>
  </ol>
  
  <p>Which is the best method?</p>
  
  <p>Thanks in advance.</p>
  
  <p>Daniele</p>