AddWarningResult(IPropertyInfo property, string description) not working when used with multiple properties

AddWarningResult(IPropertyInfo property, string description) not working when used with multiple properties

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


marthac posted on Friday, February 25, 2011

I am trying to write a rule that compares 4 properties and adds a warning result to all 4 properties when some condition exists.

In the ctor I am adding all properties to the InputProperties and adding the non-primary properties to the AffectedProperties like so: 

 

 

 

public UsiUniqueClient(IPropertyInfo lnameProperty, IPropertyInfo fnameProperty, IPropertyInfo ssnProperty, IPropertyInfo bdateProperty)
:
base(lnameProperty)
{
 if (InputProperties == null)
 {
  InputProperties =
new List<IPropertyInfo>();
 }
 InputProperties.Add(lnameProperty);//primary property
 InputProperties.Add(fnameProperty);
 InputProperties.Add(ssnProperty);
 InputProperties.Add(bdateProperty);
 AffectedProperties.Add(fnameProperty);
 AffectedProperties.Add(ssnProperty);
 AffectedProperties.Add(bdateProperty);
}

In the Execute function when the condition exists, I'm interating thru the InputProperties and calling context.AddWarningResult() for each property

int property, properties = context.Rule.InputProperties.Count;
for (property = 0; property < properties; property++)
{
 context.AddWarningResult(context.Rule.InputProperties[property],
"Test warning"); 
 System.Diagnostics.
Debug.WriteLine("Warning attached to " + context.Rule.InputProperties[property].Name);
}

It is only attaching the broken rule to the last property.

How do I get the broken rule to show up on all properties?

marthac replied on Friday, March 04, 2011

I'm beginning to think this is a CSLA bug.

I would appreciate any comments.

Copyright (c) Marimer LLC