Beispiel #1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var processor    = new SortOptionsProcessor <T, TEntity>(OrderBy);
            var validTerms   = processor.GetValidTerms().Select(x => x.Name);
            var indalidTerms = processor.GetAllTerms().Select(x => x.Name)
                               .Except(validTerms, StringComparer.OrdinalIgnoreCase);

            foreach (var term in indalidTerms)
            {
                yield return(new ValidationResult($"Invalid sort term '{term}'.", new[] { nameof(OrderBy) }));
            }
        }
Beispiel #2
0
        public IQueryable <TEntity> Apply(IQueryable <TEntity> query)
        {
            var processor = new SortOptionsProcessor <T, TEntity>(OrderBy);

            return(processor.Apply(query));
        }