Monday, March 5, 2007

OR/M and SubSonic

OR/M is the easiest way to get data out of the database without writing the code necessary to access the database. You can just use objects with methods like Load and Save. The technology is just beginning to leave its infancy stage and many libraries are difficult to configure and use. NHibernate was the first OR/M that I got working and it provides a tremendous productivity increase. However, you still have to use a code generator to create your objects to start and every time you update your DB. NHibnernate's delays in updating to a codebase where you can use generics and nullables had me looking for a new OR/M. Elementary looks interesting but you still have to generate and regenerate the class files.

SubSonic doesn't have that problem. It's written by the guy who does the Commerce Starter Kit, which I've never looked at but it seems like a good project. It's currently designed for web sites projects and uses a build provider to generate the classes. It also generates classes for views and stored procedures, which other OR/Ms don't concern with because of idealogical problems. The next release will include a custom build tool that will extend this feature to libraries and Windows Forms projects. It's also very easy to use and greatly cuts down on necessary code, even over HNibernate. Subsonic is still getting features but there's an active community.

Microsoft is working on an OR/M called LINQ that looks like it will become the de facto standard. Recent CTPs of Visual Studio Orcas have included it but I haven't used any of them. LINQ is going to have to be pretty good to beat SubSonic.

No comments: