title: Passing a user generated query down an n-tiered application
body: <p>In my application I use my Data Access Layer (DAL) to generate Plan Old CLR Objects (POCO’s) which get sent to my Business Layer (BL).  The BL then uses Model View ViewModel (MVVM) pattern to create object to bind to my Presentation Layer (PL).  </p>
  
  <p>I want to give my user the ability to filter data on the column level.  For example
  <a href="http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/filtering/defaultcs.aspx" rel="nofollow noreferrer">http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/filtering/defaultcs.aspx</a></p>
  
  <p>There are other grid controls that perform similar function but generally speaking this is the user experience I want to provide. </p>
  
  <p>I have a large dataset so I want to do all the Paging/Sorting/Filtering on the server side.  </p>
  
  <p>It is trivial to send Paging/Sorting data down the n-tiered architecture to my DAL so I would only pull the records I am interested in.  </p>
  
  <p>I am however not sure how to send Filter data to my DAL, as a user can generate an arbitrarily long filter expression.  </p>
  
  <p>My Question is: <strong>What are my options for sending user generated filter expression through my n-tired application.</strong></p>
  
  <p>My Thoughts:</p>
  
  <ul>
  <li>My life would be easier if my data
  structure was the same as my objects
  structure which was also the same as
  the view’s I present my users. 
  However my data structure can not be
  easily mapped to a users view like
  many of the control providers like to
  show in their example.</li>
  <li>Many of the Grid control providers
  offer server side functionality but
  they require one to use their Linq
  Providers.  This would break many
  elements of my architecture.</li>
  <li>The Grid controls do generate an
  expression ‘string’, which I could
  pass to my DAL and have it interpret
  it.  This however would couple my DAL
  to this particular control expression
  string format.</li>
  <li>I could create an ‘Expression Tree’
  pass it as a parameter to my DAL.  I
  would therefore only have to write a
  DAL interpreter for the expression
  tree once.  Then for any Grid control
  I would have to generate to
  appropriate expression tree to pass
  it down.</li>
  </ul>