Ejemplo n.º 1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var processor = new SearchOptionsProcessor <T, TEntity>(new [] { Query });

            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(Query) }));
            }
        }
Ejemplo n.º 2
0
        public IQueryable <TEntity> Apply(IQueryable <TEntity> query)
        {
            var processor = new SearchOptionsProcessor <T, TEntity>(new[] { Query });

            return(processor.Apply(query));
        }