✅ implementing OneOf with Repository pattern
Hey,
I'm using a repository pattern where my repos do all the communication with databases. Nothing special. I'm wondering if my repos should know about the OneOf nuget package or if that's for the service to deal with? So that the service maps whatever the repo says to a oneof type
5 Replies
What are you using OneOf for?
Does your repositories need OneOf to do anything?
Don't need perse, but it could provide clearer communication. On one hand i like the fact that an Update method could return OneOf T or something like NotFound if that entity couldn't be found and updated. However, the other part of me want to keep my repos light and not deal with a package like that. But that might be a silly opinion to hold
Seems like you want a
Result<T>
kind of a type, more than a OneOf
Or just return null
Or throw a custom exception and let the exception handling middleware handle thatWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.Missed your answer. But that's sort of what I went with. OneOf made it to "gross" in the repo. So I moved that out to the service layer.