views:

1051

answers:

1

My application is SL2 reading and writing data through an Entity Framework Model exposed via WCF. We have resisted writing any UI validation due to the exicting new validation controls coming from SL3.

...However after doing a trial update on our project yesterday, we realised that most of the standard practices for attaching validation properties to business objects can't readily be applied when the objects are created from the EF model.

Has anyone had any similiar experiences yet, if so how did you work around this?

Thanks, Mark

+1  A: 

You are correct, you have 2 options.

  1. In your model, or viewmodel, depending on your implementation of MVVM, in the setters for your properties, do some validation there, and throw an exception if there is a problem, then use SL3 ValidatesOnException property in your databinding on the view for each control being validated.

  2. use MetaDataClasses to provide addon functionality to ur existing domain model


[MetadataClass(typeof(MyMetadataClass))]
public partial class MyClass
{
  public int MyProperty { get; set; }
}

public class MyMetadataClass
{
  [Range(1,100)]
  public int MyProperty{ get; set; }
}
Neil
This looks like a good idea (metadata class) - will try that and let you know.
Mark Cooper