-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TranslateResultToActionResult doesn't give PagedInfo #71
Comments
Good question; will need to review. |
Hello Steve, I am facing the same issue. Aurélien |
This may not be the most elegant solution but given you have a StoryDto, could you create a PagedStoryDto (or whatever name) and use the return Result<IEnumerable<StoryDto>>.Success(pagedStoryDtos)
.ToPagedResult(pagedInfo)
.Map(r => new PagedStoryDto
{
StoryProperty = r.StoryProperty,
PageNumber = r.PagedInfo.PageNumber,
... // other properties
}; We might be able to add an overload of |
I did something a little bit more complex : I have overriden the
As you can see, I use reflection to Map Ardalis PagedResult and PagedInfo to my own equivalent classes Contracts.Core.Paged* With this approach, I obtain a generic solution for all my controllers and paged models. |
While using TranslateResultToActionResult to return responses in the form of ActionResults, there is no way for the caller to know the details of the pagination.
The reason is because the ToActionResult method in the ResultExtensions class just cares about the "result.GetValue()" and ignores the Pagination details which were fed by the upstream services as shown below:
return Result<IEnumerable<StoryDto>>.Success(pagedStoryDtos).ToPagedResult(pagedInfo);
Is there a way we can modify this behavior so that the caller can see the pagination details too?
The text was updated successfully, but these errors were encountered: