title: Creating database independent rules within a C# application - rules engine?
body: <p>I am writing an application using NHibernate and one of the requirements is to create rules for the system that will effectively generate SQL queries to filter data. These rules are application user maintainable.</p>
  
  <p>As an example you might have a rule for releasing orders that is called </p>
  
  <p><strong>ForeignOrders</strong>  which would be set up something like <em>Order</em> <strong>(Business Object)</strong> <em>DeliveryCountry</em> <strong>(Business Object Property)</strong> &lt;> <strong>UK</strong></p>
  
  <p>or</p>
  
  <p><strong>ExpensiveLondonAcmeOrders</strong> which would be set up something like <em>Order</em> <strong>(Business Object)</strong> <em>DeliveryCity</em> <strong>(Business Object Property)</strong> = <strong>London</strong> <em>AND</em> Order <em>TotalAmount (Business Object Property)</em>  > <strong>1000</strong> AND Order <em>CompanyName</em> = <strong>ACME</strong></p>
  
  <p>Then when the user comes to release orders they chose which rule template they want to use and will only release orders that meet those criteria.</p>
  
  <p>The names of the Business Objects and Business Object Properties closely reflect the underlying data / domain model but how would you be able to determine and display these in the user interface at run time and then create in essence the where clause for an SQL query. Also, once defined you will also need to store the values in a database with database platform independence.</p>
  
  <p>Ideally, I do not want to write this functionality - could you achieve something like this using a rules engine? If so, which and expensive ones are not really an option. If not, what resources are available to get to grips with how to write this.</p>
  
  <p>Thanks for any help it will be really useful</p>