Reputation: 663
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.
As an example you might have a rule for releasing orders that is called
ForeignOrders which would be set up something like Order (Business Object) DeliveryCountry (Business Object Property) <> UK
or
ExpensiveLondonAcmeOrders which would be set up something like Order (Business Object) DeliveryCity (Business Object Property) = London AND Order TotalAmount (Business Object Property) > 1000 AND Order CompanyName = ACME
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.
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.
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.
Thanks for any help it will be really useful
Upvotes: 1
Views: 1376
Reputation: 29629
It's worth reading "Domain driven design" by Eric Evans - it deals with a lot of the stuff you're asking for. Specifically, Evans proposes the Specification Pattern (http://en.wikipedia.org/wiki/Specification_pattern) - a way of applying boolean logic to objects without knowing in advance what the criteria are.
http://www.dimecasts.net/Content/WatchEpisode/139 has a walkthrough that may also help...
Upvotes: 1
Reputation: 70369
Rules engines won't help much... they just apply rules within a workflow...
Checkout Dynamic Linq - another option is PredicateBuilder .
Upvotes: 0