So you know that cool problem I mentioned the other day. Well before I present you with the complete solution I actually have to build up to it. First off let me start off by saying that just like most Object oriented applications that use a database, ours has an ORM layer (ORM= Object to Relational Mapping). Needless to say we rolled our own OR mapping, because at the time we felt we may not need a heavy weight one and didn’t have the time to analyze all the ORM frameworks out there. Essentially we are using delegates to pass into our database execution engine. The delegate uses IDataReader to read all the data out, because it’s a delegate the engine invokes the delegate AND gets to wrap it up in try catch logic to clean up should an exception occur.
http://www.pluralsight.com/blogs/keith/archive/2007/04/11/46711.aspx over at Pluralsight they call it enveloped abstractions. Our code is similar to what they showing at this blog.
This use of delegates is extremely cool, however it makes it a little difficult to support transactions and nested transactions (across multiple objects). Also when you throw mirroring into the equation then dual rail support (2 connection strings) things start getting a little hairy. So tomorrow I’ll be sharing some information about what I did to solve the problem