}                                     //pri request je OrderBy parameter z  query stringu mapovany do tejto property

        //ASP.NET Core calls this validate incoming parameters
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var processor    = new SortOptionProcessor <T, TEntity>(OrderBy);
            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 sort term '{term}'.", new[] { nameof(OrderBy) }));
            }
        }
        //The service code will call this to apply sort options to a database query
        public IQueryable <TEntity> Apply(IQueryable <TEntity> query)
        {
            var processor = new SortOptionProcessor <T, TEntity>(OrderBy);

            return(processor.Apply(query));
        }