예제 #1
0
        public static void Validation()
        {
            using (var context = new UniversityDB()) {
                var student = new Student()
                {
                    PIB = string.Empty
                };
                context.Students.Add(student);
                var validationErrors = context.GetValidationErrors().Where(vr => !vr.IsValid).SelectMany(vr => vr.ValidationErrors);

                foreach (var error in validationErrors)
                {
                    Console.WriteLine(error.ErrorMessage);
                }
            }
        }