protected override bool IsValid(PropertyValidatorContext context) { using (var dbContext = new DbContext ()) { var dataId = context.Instance.GetType().GetProperty("Id").GetValue(context.Instance); var result = dbContext.Set<TEntity>().Where($"{context.PropertyName} == @0 And Id!=@1", context.PropertyValue, dataId).Any(); return !result; } }
protected override bool IsValid(PropertyValidatorContext context) { if (context.PropertyValue == null) return true; ...
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)