C
C#2y 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
Thinker2y ago
What are you using OneOf for? Does your repositories need OneOf to do anything?
Zerthz
ZerthzOP2y 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
Angius2y 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
Accord2y 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
ZerthzOP2y 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.
Want results from more Discord servers?
Add your server