ArchiveQueryBuilder IArchiveQueryBuilder.WithSort(
            ArchiveQueryField sortField,
            SortDirection sortDirection)
        {
            if (_sortField != null)
            {
                throw new InvalidOperationException(
                          $"The sortField cannot be set to {sortField.ToString().ToLower().Quote()} because the " +
                          $"instance of {nameof(ArchiveQueryBuilder).SQuote()} already has the sortField " +
                          $"{_sortField.ToString().ToLower().SQuote()}.");
            }

            _sortField = sortField;

            if (_sortDirection != null)
            {
                throw new InvalidOperationException(
                          $"The sortDirection cannot be set to {sortDirection.ToString().ToLower().Quote()} because the " +
                          $"instance of {nameof(ArchiveQueryBuilder).SQuote()} already has the sortDirection " +
                          $"{_sortDirection.ToString().ToLower().SQuote()}.");
            }

            _sortDirection = sortDirection;

            return(this);
        }
Example #2
0
 public static ArchiveQueryBuilder WithSort(
     this ArchiveQueryBuilder @this,
     ArchiveQueryField SortField,
     SortDirection sortDirection)
 {
     return(@this
            .As <IArchiveQueryBuilder>()
            .WithSort(
                SortField,
                sortDirection));
 }