-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Add support for TransactionScope #2
Comments
Very good job. |
You will get invalid data when a transaction is present. |
I made some changes to support Transactions. Could you review it, please? Thank you |
Sorry, I don't offer consulting services. It also has been a few years since I did any serious development for .NET and re-focusing would require time I cannot afford at the moment. |
Ported from: https://efcache.codeplex.com/workitem/10
REPORTED ON:
REPORTED BY:
Nov 5, 2014 at 7:28 PM
icnocop (contact)
Hi.
Thank you for EFCache.
I'd like to request support for caching within a transaction scope.
EDIT [moozzyk]
The code snippet is irrelevant since it does not use
TransactionScope
and should work correctly; See my comment below./EDIT
Currently, the entity sets that are indicated as cache-able do not behave as being cached when queried and the database is explicitly queried every time.
Thank you.
comments
moozzyk wrote Nov 11, 2014 at 10:37 PM [x]
I agree it would be useful to add support for TransactionScope
However, the code snippet you provided is not relevant for two reasons:
it does not use TransactionScope at all - Database.BeginTransaction() will start a regular DbTransaction and will not create an ambient (potentially distributed) transaction TransactionScope would create
since the code you provided is not using a TransactionScope EF would call the DbTransactionInterceptor on commit and on rollback meaning that the cache would work correctly since it already intercepts transaction calls to invalidate cache on commit
icnocop wrote Dec 23, 2014 at 1:34 PM [x]
Thank you.
However, I noticed that the cache is not persisted using using BeginTransaction() within a loop.
For example:
Thank you.
moozzyk wrote Dec 26, 2014 at 8:00 PM [x]
Yes, for simplicity results for queries issued inside transactions are not cached (you can see it here: https://github.com/moozzyk/EFCache/blob/master/EFCache/CacheTransactionHandler.cs). This is because I would have to track them separately and merge the when the transaction is committed. In general it is best practice to keep the transaction as short as possible and do as few reads as possible. Note that EF by default will only create a transaction when saving results to the database (i.e. when you call SaveChanges) and won't create transactions for queries.
The text was updated successfully, but these errors were encountered: