views:

76

answers:

2

Hello, subject is...

I have a Linq to SQL class that i need to define a "rule engine" before saving it back to the database, this of course involves all foreign keys - associations, common, the whole object graph i created and manipulated, or value changed object from the database.

Thing is, i don't have any experience on the subject and i would love couple of suggestions. This rules are going to validate fields based on a property value, in case, different fields are necessary and others not.

Now i have this feeling that there should be a pattern to implement this more robust and "proper"! First thing i thought, was just passing the object inside a util class where there should all necessary validations will happen and return result.

Any help appreciated. Thanx

A: 

Take a look at the Specification pattern. You can use generics to make the examples on the wiki page type-safe.

Bryan Watts
Thanx for suggestion
A: 

are your rules dynamic ? you can use workflow foundation. Here is the documentation from MSDN

ram