I have a table (junction table) with 3 primary keys so when I want to check duplicate records , I must check 3 properties together
I wrote a method like this
private bool IsDuplicate(long roleId, long componentGroupId, long operationId)
{
var business = new RoleGroupBusiness();
var result = business.Where(x => x.RoleID == roleId && x.ComponentGroupID == componentGroupId && x.OperationID == operationId).Any();
return result;
}
and I have a FluentValidator class like this :
public class RoleGroupValidator : AbstractValidator<RoleGroup>
{
private bool IsDuplicate(long roleId, long componentGroupId, long operationId)
{
var business = new RoleGroupBusiness();
var result = business.Where(x => x.RoleID == roleId && x.ComponentGroupID == componentGroupId && x.OperationID == operationId).Any();
return result;
}
public RoleGroupValidator()
{
RuleFor(x => x.RoleID).NotNull().WithMessage("A");
RuleFor(x => x.ComponentGroupID).NotNull().WithMessage("A");
RuleFor(x => x.OperationID).NotNull().WithMessage("A");
}
}
1) How can i use IsDuplicate methid in FluentValidator ?
or
2) What is best way for checking entity is Duplicate or not in fluentValidation Library ?
RuleFor only get me value of one of properties but I need value of all properties for passing to my method