title: MVVM ViewModel to Model communication and parameters
body: <h2>Background</h2>
  
  <p>I think I have the answer to this one already, but I'm trying to adhere as closely to MVVM as I can, and learning a ton a long the way.</p>
  
  <p>I currently have my View, ViewModel, and Model set up. My Model is querying a database using entity framework.</p>
  
  <p>My View has a bunch of controls to allow the user to set up the parameters of the query (basically building a big where clause).ViewModel stores these options set through the controls.</p>
  
  <p>So my view-view model interaction seems pretty spot on, and I think it's acceptable.</p>
  
  <h2>The Problem</h2>
  
  <p>My model exposes a function which returns the results of the query as some kind of IEnumerable. The problem I'm now having is the number of "search criteria" I'm having the user set. I now have <strong>9</strong> parameters for the model function. I don't know if it's acceptable. At the very least, it's ugly. Very ugly. But this way, my viewModel only needs to hold an instance of the model, and then only needs to know that one function and its signature. </p>
  
  <h2>The Question</h2>
  
  <p>Should I be setting up properties in the Model and then setting those properties in the View Model? This way the single function will be much cleaner, but the view model will have to be more "aware" of what properties the model has. I know this isn't a big deal to just create some public properties, but I would like to know which is more acceptable for MVVM. Our current code base has no separation of concerns. So I'm on my own on this one.</p>
  
  <h2>The Code in Question</h2>
  
  <h3>Current Model Function:</h3>
  
  <pre><code>public IEnumerable&lt;&gt; GetResults(string id, string inputName, DateTime? fromDate,
      DateTime? toDate, bool option1, int selectCount, bool exactMatch = true, bool showFailed = false)
  {
      //QUERY HERE, returns results
  }
  </code></pre>
  
  <p>Relevant ViewModel call:</p>
  
  <pre><code>var queryResults = MyModel.GetResults(id, inputname, FromDate, ToDate, Option1, selectCount, ExactMatch, ShowFailed);
  Results = queryResults.ToList();
  </code></pre>
  
  <h3>Proposed Model:</h3>
  
  <pre><code>public string Id          {get;set}
  public string InputName   {get;set}
  public DateTime? FromDate {get;set}
  public DateTime? ToDate   {get;set}
  public bool Option1       {get;set}
  public int SelectCount    {get;set}
  public bool ExactMatch    {get;set}
  public bool ShowFailed    {get;set}
  
  public IEnumerable&lt;&gt; GetResults()
  {
      //Query here, return results
  }
  </code></pre>
  
  <p>Relevant Proposed ViewModel call:</p>
  
  <pre><code>MyModel.Id = this.Id;
  MyModel.InputName = this.InputName;
  MyModel.FromDate = this.FromDate;
  //...etc (I put the this. to clarify the view model also has those properties).
  var results= MyModel.GetResults();
  </code></pre>