AsyncRuleHandler & IsNew

AsyncRuleHandler & IsNew

Old forum URL: forums.lhotka.net/forums/t/8127.aspx


opedog posted on Friday, December 11, 2009

Morning, as part of a business rule I'm trying to write, I need to check 2 things:
  1. IsNew == true, and
  2. if a certain key already exists in the DB
The server call is easy, just a simple AsyncRuleHandler, but I don't seem to have a way to check IsNew (since you can't add an AsyncRuleHandler as an instance validation rule.)

Any thoughts?

Thanks!

Michael Yarbrough

RockfordLhotka replied on Friday, December 11, 2009

When you call AddRule() to add an async rule method to a property, there's an optional overload of AddRule() where you can pass an array of other properties that should be provided to the rule method.

The array is of IPropertyInfo objects - and there's no IPropertyInfo for IsNew... But you can add one to your class - it shouldn't cause any issue since it is just metadata - and then you'd be able to have the rules subsystem provide the IsNew value to your rule method.

opedog replied on Monday, December 14, 2009

I am kicking myself for not thinking of that...  Thanks, Rocky!

Copyright (c) Marimer LLC