CommonRules.IntegerMinValue

CommonRules.IntegerMinValue

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


bones posted on Tuesday, January 09, 2007

Can someone please tell me if I am adding this CommonRule incorrectly, syntactically?  I cannot find any examples of this rule being used in any sample code or forums.  I think its a simple syntax error but I am unsure.  I ended up writing my own custom rule to do what this built in rule does and I'm not happy about doing this.  I want to use the CommonRule.

ValidationRules.AddRule(CommonRules.IntegerMinValue, new CommonRules.IntegerMinValueRuleArgs("ModifiedBy", 1));

 

ajj3085 replied on Tuesday, January 09, 2007

bones:
ValidationRules.AddRule(AddressOf CommonRules.IntegerMinValue, new CommonRules.IntegerMinValueRuleArgs("ModifiedBy", 1));


Don't you need AddressOf as I added above?  I'm not a VB guy though, so I'm not sure..

Thunderstruck replied on Tuesday, January 09, 2007

You absolutely need AddressOf if you are using VB.  Also, are you importing the Validation namespace?  If not, you need to prefix your stuff (i.e. Validation.CommonRules.IntegerMinValue).

bones replied on Tuesday, January 09, 2007

I'm writing in C#

Michael Hildner replied on Tuesday, January 09, 2007

The syntax looks fine. What are the details of the error you're getting?

bones replied on Tuesday, January 09, 2007

Here's the error I am getting:

Tests.AccountContactFixture.GetAccountsContactsByAccount : AI.Core.DataPortalException : DataPortal.Fetch failed (System.ArgumentException: Property Get method was not found.
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   at AI.Core.Utilities.CallByName(Object target, String methodName, CallType callType, Object[] args)
   at AI.Core.Validation.CommonRules.IntegerMinValue(Object target, RuleArgs e)
   at AI.Core.Validation.RuleMethod.Invoke(Object target)
   at AI.Core.Validation.ValidationRules.CheckRules(List`1 list)
   at AI.Core.Validation.ValidationRules.CheckRules()
   at AI.Library.CustomerRelationshipManagement.AccountContact..ctor() in C:\Documents and Settings\acardoza\My Documents\Visual Studio 2005\Projects\AI.Library.CustomerRelationshipManagement\Engine\AccountContact.cs:line 228
   at AI.Library.CustomerRelationshipManagement.AccountContact.Get(IDataReader dr) in C:\Documents and Settings\acardoza\My Documents\Visual Studio 2005\Projects\AI.Library.CustomerRelationshipManagement\Engine\AccountContact.cs:line 216
   at AI.Library.CustomerRelationshipManagement.AccountContactCollection.DataPortal_Fetch(Criteria crit) in C:\Documents and Settings\acardoza\My Documents\Visual Studio 2005\Projects\AI.Library.CustomerRelationshipManagement\Engine\AccountContactCollection.cs:line 186)
  ----> AI.Core.Server.CallMethodException : DataPortal_Fetch method call failed
  ----> System.ArgumentException : Property Get method was not found.

ajj3085 replied on Tuesday, January 09, 2007

Opps.. I missed the semicolon at the end.

It looks like you don't have a Property Get method defined on the property your checking.

bones replied on Tuesday, January 09, 2007

You know what, you are right.  I am upgrading someone else's code so I haven't really combed through it thoroughly enough yet.  But that's exactly it.

It probably helps to read the exceptions more carefully!

Thanks!

Copyright (c) Marimer LLC