Monday, August 31, 2009

Entity Framework Provider Wrappers

The following open source project is hopefully a preview of the extensibility that is to be added to the Entity Framework: . Had to make a couple of adjustments and fixes, but after that it runs fine and speeds up data access quite a bit. I have mostly looked at the caching, still need to spend some time on the tracing. Fixes made to the caching code:
  • Modifications are not cacheable. Results of an insert should not be cached :) .
  • Extended the cached data so that more methods in the wrapped reader could be implemented. For instance the field names and schema.
  • Don't cache when the data reader hasn't been read to the end.
  • Fixed the loading of assemblies (done to find the referenced EF files) so it works better with GAC-ed assemblies.
  • Fixed a rather nasty issue in DbCommandTreeScanner. This class implements the visitor pattern for a command tree and is needed to determine the affected entity sets. However, in certain large statements (yes, the question is if it is wisdom to use those, but that's a different issue), this resulted in a stack overflow. Auch. By pruning constants out of the visited expressions early on, I was capable of avoiding the stack overflow.

Besides that, I extended the caching policy so that the expiration can be specified by entity. When multiple entities are affected, I take the smallest expiration across the affected entities.

With a little work, the provider wrapper turns out to be rather useful.

No comments:

Post a Comment