protected virtual SortExpression GetSort(IReadOnlyCollection <QueryExpression> expressionsInScope, ResourceContext resourceContext) { ArgumentGuard.NotNull(expressionsInScope, nameof(expressionsInScope)); ArgumentGuard.NotNull(resourceContext, nameof(resourceContext)); var sort = expressionsInScope.OfType <SortExpression>().FirstOrDefault(); sort = _resourceDefinitionAccessor.OnApplySort(resourceContext.ResourceType, sort); if (sort == null) { var idAttribute = GetIdAttribute(resourceContext); sort = new SortExpression(new SortElementExpression(new ResourceFieldChainExpression(idAttribute), true).AsArray()); } return(sort); }
protected virtual SortExpression GetSort(IReadOnlyCollection <QueryExpression> expressionsInScope, ResourceContext resourceContext) { if (expressionsInScope == null) { throw new ArgumentNullException(nameof(expressionsInScope)); } if (resourceContext == null) { throw new ArgumentNullException(nameof(resourceContext)); } var sort = expressionsInScope.OfType <SortExpression>().FirstOrDefault(); sort = _resourceDefinitionAccessor.OnApplySort(resourceContext.ResourceType, sort); if (sort == null) { var idAttribute = resourceContext.Attributes.Single(x => x.Property.Name == nameof(Identifiable.Id)); sort = new SortExpression(new[] { new SortElementExpression(new ResourceFieldChainExpression(idAttribute), true) }); } return(sort); }