❔ Method either receive a disposable [context] or use a new one (EFCore - Blazor)
I'm in a blazor project where I wanna reuse some query functions.
Basically sometimes I either
1. Wanna use the method on itself where it should create and dispose a new context created by the contextFactory.
2. Wanna use the method inside another method that already has a context, and just wanna pass it so it doesn't create an unneccesary one.
What I currently thought of is this:
However I do not like the idea of manually disposing when a context is not passed.
Are there any other ideas on how to approach this?
2 Replies
Instead of dealing with the context, another idea is splitting entirely the query on itself to only mess around with IQueryables so it can be reused:
Could also be an extension method
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.