views:

201

answers:

1

Is there any event like OnValidate in LINQ where I can add my business validation rules so that they are ALWAYS called whenever I use Add() or Update()?

If not: What do you suggest to do? I could add a partial class and wrap the Add/Update methods with own ones but then one could still use the original ones ignoring any business validation rules.

Thanks in advance and keep up the excellent work with subsonic!

+1  A: 

I haven't used much of the LINQ parts of SubSonic3, but the ActiveRecord.tt file allows you to customize the code so you could insert an validate method. We talked about it over at http://stackoverflow.com/questions/1295842/how-to-intersept-the-save-method-on-activerecord/1331469#1331469

Can you modify the tt file to add in your validation call before saving the record?

Jim W
Yeah, that works just fine.Thank you very much for your help!
If that works, then don't forget to mark this question as answered. That will keep it from appearing in everyone's unanswered list. Thanks
Jim W