title: C#, Linq, Dynamic Query: Code to filter a Dynamic query outside of the Repository
body: <p>If you do something like this in your Repository:</p>
  
  <pre><code>IQueryable&lt;CarClass&gt; GetCars(string condition, params object[] values) {
      return db.Cars.Where(condition, values);
  }
  </code></pre>
  
  <p>And you set the condition and values outside of the repository:</p>
  
  <pre><code>string condition = "CarMake == @Make";
  object[] values = new string[] { Make = "Ford" };
  
  var result = myRepo.GetCars( condition, values);
  </code></pre>
  
  <p>How would you be able to sort the result outside of the repository with Dynamic Query?</p>
  
  <pre><code>return View( "myView", result.OrderBy("Price"));
  </code></pre>
  
  <p>Somehow I am losing the DynamicQuery nature when the data exits from the repository.  And yes, I haven't worked out how to return the CarClass type where you would normally do a Select new Carclass { fieldName = m.fieldName, ... }</p>