Exemple #1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var processor = new FilterOptionsProcessor <T, TEntity>(Filter);

            var validTerms   = processor.GetValidTerms().Select(x => x.Name);
            var invalidTerms = processor.GetAllTerms().Select(x => x.Name)
                               .Except(validTerms, StringComparer.OrdinalIgnoreCase);

            foreach (var term in invalidTerms)
            {
                yield return(new ValidationResult(
                                 $"Invalid search term '{term}'.",
                                 new[] { nameof(Filter) }));
            }
        }
Exemple #2
0
        public IQueryable <TEntity> Apply(IQueryable <TEntity> query)
        {
            var processor = new FilterOptionsProcessor <T, TEntity>(Filter);

            return(processor.Apply(query));
        }