I have a stand-alone console app which polls the db periodically for changes.
I want to ensure if anyone makes changes to the Db from the web front-end, the console app gets an updated list of entities.
I’ve been looking at the .Reload() method but this seems to work only on a single entity. I want my select statement on the repository layer to get a refreshed list, as well as any item changes within the list. Effectively a refresh of the whole context for this particular entity.
How do I achieve this, without creating a new context? The reason for not creating a new context is that I want to be able to still unit test and inject the repo into the consuming service without creating a concrete implementation inside the service.
Why do you need long living context? You didn’t mentioned any valid reason. You can inject factory instead of context to your service. Factory will hide context creation and your service will be able to create as many contexts as it needs to. Long living context is problematic and should be avoided.
Anyway if you need to refres some data you can change
MergeOptionfor the set (orObjectQuery):