C
C#15mo ago
Zerthz

✅ 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
Thinker
Thinker15mo ago
What are you using OneOf for? Does your repositories need OneOf to do anything?
Zerthz
Zerthz15mo ago
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
Angius
Angius15mo ago
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 that
Accord
Accord15mo ago
Was 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.
Zerthz
Zerthz15mo ago
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.