Casting Results<T1, ... Tn> to another Results<T1, ... Tn> #56921
Unanswered
kieronlanning
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've a helper method for performing list operations. All of the list APIs take a
ListRequest
record
(viaAsParameters
), or something that inherits from it - all taking a DBContext, Validator, PageNum and PageSize.This works for 90% of the list endpoints I have:
However... if I need to introduce another
IResult
type, likeNotFound
for example there is no casting I can use to make this work:In this instance, there is a parent
Group
on theListRequest
derivedListByGroupRequest
. And if it's not found then it needs to returnNotFound
- this situation seems impossible.I'm a huge fan of the minimal APIs, and the fact I can use it to accurately generation OpenAPI docs is a real win. But I'm struggling to find out how to do some of these basic reusable methods.
For the sake of clarify, the
Http.ListAsync
andListRequest
method looks like this:Beta Was this translation helpful? Give feedback.
All reactions