A repository that works with multiple O/R mappers — is it possible?

A recent post on the WilsonORWrapper Google group talked about making WORW multi-database aware by removing static classes and singletons. Well, I’ve kind of been thinking of something similar lately…

For some time I have been toying with the idea of rewriting WORW to support a generic repository service that would work with any O/R mapper, much
like the logger and cache services work over different underlying libraries. By removing the static classes and singletons and adding a provider model for the O/R wrapper element, you would be able to instantiate multiple instances of a “Registry” class, a class which provides a set of services (Repository, Cache, Logger, etc.) based on a given configuration criteira.

As a test I wrote up a simple project (with unit tests!) as a proof-of-concept, using WORM and NPersist as underlying O/R mappers. The WORM part worked fine. The NPersist part almost worked — however, I believe the errors are related to using NPersist’s not-too-well-documented XML provider, not errors with the O/R mapper provider itself (NPersist does initializes properly, which indicates at least something is working right).

If you’re interested in seeing this little stub of a project, download the source (27.5kb). I’ve dubbed it NRepository right now, not for any reason except it’s the first thing that came to mind. Let me know what you think, and whether you think it’s worth pursuing such a project.

Performance tweaks and bug fixes to WilsonORWrapper

A minor update today (with one breaking change) to WilsonORWrapper:

  • BREAKING CHANGE: Renamed RetrieveTotalRecordCount() to GetObjectCount().
  • Implemented SQL2005 paging support by passing dummy where clause when none specified (they are required with SQL2005 paging); this is a hack, not a fix; you should always specify a sort clause when using any paging operation!
  • Cached value of EntityBase.IsReadOnly on first load; allowed dummy set operator to permit ObjectDataSource usage.
  • Improved IdentityBase.GetHashCode performance with single column keys.
  • Refactored to ensure mapping file stream is disposed.

Thanks to Michael Mepham for help in identifying and resolving these issues. The latest source code is available in ZIP format; no compiled binaries yet.

Wilson.ORMapper subscriber source code repository

Many users of Paul Wilson’s O/R mapper (“WORM”) know that there are a number of community-provided patches which are out there but not incorporated in any official release. Personally, I have maintained a copy of the source code in a private Subversion repository and incorporated a number of these patches for my own use. (Access to the full source code of WORM require you to pay a very reasonable $50 “subscriber fee” to Paul Wilson.)

I contacted Paul Wilson yesterday, asking him if he’d let me grant access to this repository to people who are WORM subscribers. Fortunately for all involved, he said yes!

What does this mean for you? If you are a subscriber to WORM, you can send me your full name and email address and request access to this private repository. I will confirm your subscription with Paul and grant you access.

The following changes have been incorporated into the aforementioned WORM instance:

The purpose of opening up this Subversion repository to subscribers is to give us all a place to share and contribute to a central copy of WORM that includes all the improvements and patches we maintain individually.

If you want to participate, send me your full name and email address.

First community patch applied to WilsonORWrapper

Hot on the heals of yesterday’s update, I just received and applied the first community patch to WilsonORWrapper.

The patch, from Wayde Gilliam, adds the following:

  • Added MemberPrefix option to mappings generator, allowing member prefix (private field) customization
  • Added SetProperties method allowing dictionary-based changes
  • Added IncludeList option to mappings generator, allowing selective table inclusion (combines functionality with IgnoreList)

Hats off to Wayde for a well-written patch!

Release 43 (download source code) has the aforementioned changes, as well as an update to the readme file which gives kudos to Wayde and to Gunter Spranz, an early-adopter of this project whose insight and input was invaluable in the development of the product as we see it today.

Thanks to both — and don’t forget to go ahead and send in your own patch!