Created
April 27, 2020 07:23
-
-
Save papeMK2/dba3727267b3ed7e8c608417be46e608 to your computer and use it in GitHub Desktop.
Custom validation with DbContext
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using papemk2.Entities.Db; | |
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel.DataAnnotations; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace papemk2.Attributes | |
{ | |
public class CustomValidationAttribute : ValidationAttribute | |
{ | |
public CustomValidationAttribute() | |
{ | |
} | |
protected override ValidationResult IsValid(object value, ValidationContext validationContext) | |
{ | |
papemk2DbContext context = (papemk2DbContext) validationContext.GetService(typeof(papemk2DbContext)); | |
return base.IsValid(value, validationContext); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment