-
Presently I am using Functional Extension in following way `Result a= await ResolveEntityAFromDb(request.AId, token); Result b = await ResolveEntityBFromDb(request.BId, token); EntityC c = Map(a.Result, b.Result, request); return Result.Success;` I want to avoid having if(a.IsFailure), if (b.IsFailure) checks and make it railway oriented. Any Ideas of how I can chain such operations and use results of all previous operations (ResolveEntityAFromDb, ResolveEntityBFromDb) in last step. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi, you can use something like return ResolveEntityAFromDb(request.AId, token)
.Bind(result1 => ResolveEntityBFromDb(request.BId, token).Map(result2 => (result1, result2))
.Map(tuple => Map(tuple.result1, tuple.result2, request))
.Tap(() => dbContext.SaveChanges()); |
Beta Was this translation helpful? Give feedback.
-
Yeah, we can add the additional extension for sure. I usually use a workaround like this: Result result1 = ResolveEntityAFromDb(request.AId, token);
result1.Bind(_ => ResolveEntityBFromDb(request.BId, token)
.Map(entityB => Map(result1.Value, entityB).
.... |
Beta Was this translation helpful? Give feedback.
Hi, you can use something like