Background
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.
I currently have my View, ViewModel, and Model set up. My Model is querying a database using entity framework.
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.
So my view-view model interaction seems pretty spot on, and I think it's acceptable.
The Problem
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 9 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.
The Question
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.
The Code in Question
Current Model Function:
public IEnumerable<> GetResults(string id, string inputName, DateTime? fromDate,
DateTime? toDate, bool option1, int selectCount, bool exactMatch = true, bool showFailed = false)
{
//QUERY HERE, returns results
}
Relevant ViewModel call:
var queryResults = MyModel.GetResults(id, inputname, FromDate, ToDate, Option1, selectCount, ExactMatch, ShowFailed);
Results = queryResults.ToList();
Proposed Model:
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<> GetResults()
{
//Query here, return results
}
Relevant Proposed ViewModel call:
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();