Hi all,
In my Silverlight application, I am currently using a domain service with a
Custom Validation
attribute on my meta class.
In this particular case, I have to reference a field from another associated
table to determine
whether a field is required.
My class is called Term.
It contains a reference field TermTypeID, and a decimal field Amount.
In the TermType table I have a field called HasAmount (bool).
If the TermType selected requires an amount to be entered against the Term, the
HasAmount
property is true against that particular term type.
So if I follow the TermType to get the HasAmount field, and if the HasAmount
field is true, then the
user is required to enter an Amount in the term.Amount field.
Within my dbml file (LinqToSql), I have a reference between the Term table and
the TermType
table.
My validation routine looks like this:
public static ValidationResult ValidateTerm(Term currentTerm)
{
if (currentTerm.TermType.HasAmount)
{
if (currentTerm.Amount == null)
{
return new ValidationResult("Amount is required for the selected
Term Type.");
}
else if (currentTerm.Amount <= Decimal.Zero)
{
return new ValidationResult("Amount must be a positive value.");
}
}
}
When the CustomValidation executes on the client, the TermType object is
populated, and the
ValidateTerm method is executed correctly.
But when it executes on the server side, the TermType object is not populated
(null).
Does anyone know what the "correct" way to approach this sort of requirement is
with Custom
Validation?
Regards,
Tony
_______________________________________________
ozsilverlight mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight