Replies: 1 comment 1 reply
-
Not sure what you're asking here? You're using 5 non-language-ext libraries and just one type from language-ext ( If you want to get more into an FP style then check out the wiki. Starting with the Thinking Functionally tutorials. Once you understand the basics then it's worth looking at the How to deal with side effects section as it covers wrapping up your IO (talking to databases, etc.) in a runtime which can then be composed with zero awaits (the |
Beta Was this translation helpful? Give feedback.
-
Noob here. I am implementing a simple edit endpoint in a minimal api in .Net 8.0 following the Domain, Application, Infrastructure, WebApi architecture, using MediatR to handle request.
Suppose I want to edit one
Entity
I have a
Get
repository method that returnsTask<Option<Entity>>
:And Update:
Then I have a handler for the edit request that initially i wanted to implement it like this:
Finally I have the endpoint :
This code returns an exception
Unhandled exception. System.ObjectDisposedException: Cannot access a disposed context instance. Object name: 'ApplicationDbContext'.
I got it to work changing the handler like this:
Then the endpoint like this:
That is a lot of awaits... Surely I am misusing this features... Please can someone clarify me what's the best approach in this kind of situations? Thanks. I have read the docs and seen the ContoseApp sample but that did not help much...
Beta Was this translation helpful? Give feedback.
All reactions