TLDR version:
Is it possible to use the Dapper ORM to manually update already-existing in-memory object instances to the latest values in the DB rather than always returning new instances?
Longer version:
We have built our own caching mechanism to support our object models. At the same time, we really like the convenience of how Dapper can create and return objects to us from simple SQL calls using anonymous types to specify the parameters. As such, we're trying to leverage both.
What we're dealing with is we make the database the gospel of the data, using triggers and such to ensure it's integrity. Then we need to refresh our existing in-memory objects to reflect those new values. We don't care if it's a manual process which we have to explicitly call, but I don't see any way to intercept Dapper 'new'ing up the objects and instead hand them an object to update.
So, can Dapper do anything like that, or is that something we're going to have to implement on our own?
No, Dapper does not have any sort of persistence, observable, or reusable mechanic. All you can do is re-query and reassign to your existing object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With