using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ServiceModel; namespace SchoolSample.EntityModel { public partial class Course { /// <summary> /// Static constructor to initialize ValidateEntityOnPropertyChanged /// </summary> static Course() { #if (WPF) ValidateEntityOnPropertyChanged = false; #endif } /// <summary> /// Partial method to add all validation actions /// defined for this class /// </summary> partial void InitializeValidationSettings() { AddPropertyValidationAction("InstructorId", ValidateInstructorId); } #region "Private Validation Methods" /// <summary> /// Validation Action: /// check whether InstructorId is not equal to zero /// </summary> /// <param name="value"></param> private void ValidateInstructorId(object value) { int instructorId = (int) value; if (instructorId == 0) { #if (WPF) ValidationResult result = new ValidationResult("Please choose a valid instructor ID.", new List<string> { "InstructorId" }); AddError("InstructorId", result); #else FaultReason faultReason = new FaultReason("InstructorId is not valid."); throw new FaultException(faultReason); #endif } } #endregion "Private Validation Methods" } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)