// If any Model rules broken, set SelectedCommonDataType Errors collection 
        // which are data bound to UI error textblocks.
        private void DisplayEntityErrorMessages(ModelValidationResult modelValidationResult) {
            var entityUpdateErrors = new Dictionary<string, ReadOnlyCollection<string>>();

            // Property keys format: address.{Propertyname}
            foreach (var propkey in modelValidationResult.ModelState.Keys) {
                string propertyName = propkey.Substring(propkey.IndexOf('.') + 1); // strip off order. prefix

                // 'modelValidationResults.ModelState[propkey]' is the collection of string error messages
                // for the property. Later on in UILayer, FirstErrorConverter will display the one of the collection.
                // 'propertyName' will only occur once for each property in the Model so a new ReadOnlyCollection
                // can be created on each pass of the foreach loop.
                entityUpdateErrors.Add(propertyName, new ReadOnlyCollection<string>(modelValidationResult.ModelState[propkey]));
            }

            if (entityUpdateErrors.Count > 0) {
                SelectedEntity.Errors.SetAllErrors(entityUpdateErrors);
            }
        }
 public ModelValidationException(ModelValidationResult validationResult)
 {
     ValidationResult = validationResult;
 }