title: HotTowel - Durandal navigation to view with filter predicate to Breeze as parameter
body: <p>I am not clear how to implement architecture-wise the navigation to a new view with filter predicate as parameter in MVC4 SPA HotTowel template.
  Lets say I have a home view with dropdown with dates (filter) and a button "gotoSessions" to navigate to the Sessions view. GoToSessions button will navigate to the Sessions view displaying the sessions for the selected date only. Not selecting a date will force the Sessions View to display all available sessions.  </p>
  
  <p><img src="https://i.stack.imgur.com/uCsBk.png" alt="Home View Screen Added"></p>
  
  <ol>
  <li><p>Update the "sessions" route in config.js to accept filter parameter</p>
  
  <pre><code>var routes = [{
      url: 'sessions/:filter',
      moduleId: 'viewmodels/sessions',
      name: 'Sessions',
      visible: true,
      caption: '&lt;i class="icon-book"&gt;&lt;/i&gt; Sessions' }, {... the rest of the routes ..}];
  </code></pre></li>
  <li><p>Implement the "gotoSessions" button </p>
  
  <pre><code> var selectedDate = ko.observable();
  
   var gotoSessions = function(viewData) { 
     if (viewData &amp;&amp; viewData.selectedDate) {
        // build filter to pass to Breeze QueryManager as where clause
        var filter = viewData.selectedDate.peek();
  
        // build url with filter parameter
        var url = '#/sessions/' + predicate;
  
        router.navigateTo(url);
     }
  };
  </code></pre></li>
  <li><p>In the sessions.js viewmodel update the activate method to accept routeData as parameter
  and implement filtering in the datacontext.js service</p>
  
  <pre><code>var activate = function (context) {
     var filterParam = context.filter;
  
     // update datacontext getSessionsPartials method to accept filter parameter
     return datacontext.getSessionsPartials(sessions, false, filterParam ); 
  };
  </code></pre></li>
  <li><p>In the services/datacontext.js update the query to use the filter</p>
  
  <pre><code>var getSpeakersPartials = function (speakersObservable, forceRemote, filter) { 
  //... code ... 
     var query = EntityQuery.from('Speakers')
       .select('id, firstName, lastName, imageSource')
       .where(... filter here ...)
       .orderBy(orderBy.speaker);
       //... rest of the code...
  };
  
  function getLocal(resource, filtering, ordering) {
     var query;
     if (filtering) {
        query = EntityQuery.from(resource)
             .where('yourPropertyNameHere', 'equals', filtering)
             .orderBy(ordering);
     }
     else {
         query = EntityQuery.from(resource).orderBy(ordering);
     }   
  }
  </code></pre></li>
  </ol>
  
  <p>Is this the correct implementation for the MVC4 SPA HotTowel architecture?
  Can you please give code example for the filter (predicate) formating?
  Thanks</p>