You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a requirement to merge multiple results of type Result<IEnumerable<T>>. Here is an example of what Im trying to do:
Result<IEnumerable<SomeDto>>result= Result.Ok(Enumerable.Empty<SomeDto>());if(someCondition){Result<IEnumerable<SomeDto>>dbResult=await CallSomeDbFunc();result= Result.Merge(result, dbResult);}if(result.IsSuccess &&someCondition){// run another db function and merge with `result`}
With the above code, Result.Merge is returning Result<IEnumerable<IEnumerable<SomeDto>>>>. What I would rather it return is the input's result type.
In order to achieve what I want, Im using ToResult to "unwrap" the return from Result.Merge.
I have a requirement to merge multiple results of type
Result<IEnumerable<T>>
. Here is an example of what Im trying to do:With the above code,
Result.Merge
is returningResult<IEnumerable<IEnumerable<SomeDto>>>>
. What I would rather it return is the input's result type.In order to achieve what I want, Im using
ToResult
to "unwrap" the return fromResult.Merge
.Is this the recommended way or have I missed a method signature somewhere?
The text was updated successfully, but these errors were encountered: