SubSonic v1 (ActionPack) vs dOOdads vs Castle ActiveRecord

Posted Monday, May 07, 2007 4:05 PM by Mischa Kroon

SubSonic Vs dOOdads Vs ActiveRecord

Let's meet our contenders:

dOOdads

An ORM framework which was provided by the people who also gave us MyGeneration.
It's built with a couple of things in mind:

- Ease of use
- Supporting a large amount of DBMS systems

Summary

MyGeneration presents dOOdads, an elegant .NET architecture available in C# and VB.NET and capable of supporting any .NET managed data provider. Currently dOOdads are available for Microsoft SQL, Oracle, Firebird, Access, PostgreSQL, VistaDB, SQLite, and MySQL.
 

Castle's ActiveRecord

ActiveRecord is the DAL which is supplied with the Castle project.

Summary

The Castle ActiveRecord project is an implementation of the ActiveRecord pattern for .NET. The ActiveRecord pattern consists on instance properties representing a record in the database, instance methods acting on that specific record and static methods acting on all records.

Castle ActiveRecord is built on top of NHibernate, but its attribute-based mapping free the developer of writing XML for database-to-object mapping, which is needed when using NHibernate directly.

SubSonic

The first public DAL which employed Build Providers that I know off :)

Summary

A Data Access Layer (DAL) builder that requires no code on your part, it builds itself at compile-time with a full object layer and strongly-typed Collections
A complete utility toolset, complete with Rails-like scaffolding, migrations (DB Versioning), and code generators
A dynamic query tool, that lets you use SQL Server and the Enterprise Library without having to know SQL
An OR Mapper that extends to views and stored procedures so you're not locked into the OR/M thing


The syntax / setup by ORM:

Setup dOOdads:

Install MyGeneration code generator Create stored procedures ( optrional ), Create DAL.
Copy files to current project folder.

Copy DLL and your done.
Setting the connectionstring can be done in the appsettings: "dbconnection" is it's default.

Setup Active Record:

Generate Classes using Active Record Generator (Sql Server only), or through several other methods. Generating the classes is pretty wrist friendly.
Just setting property's for every column and defining it's relationship is enough. b

It also needs a section in the web.config or a bit of code to set it up and a couple of DLL's

Setup SubSonic:

Classes can be generated by using a build provider, which means as much as have let VS.Net create the classes at build time which means you don't have to manually have to update the classes. ( Needs full trust )

Classes can also be generated trough the supplied templates which are called through a web interface.

It also needs a section in the web.config or a bit of code to set it up and a single DLL.

Setup Conclusion:

All have different approaches with none of them actually having a leg up on the others at least not for me.

They can all be set up within 10 - 20 minutes and are thus also usable for small projects.

-----

The Code for some standard actions:

In this table the code for the active record solutions is missing this is because I couldn't really find any documentation in a downloadable form for this framework on how to do these things. (which doesn't mean that it's not out there :)

dOOdads Active Record SubSonic

Retrieving all records of a table

Dim emps As New Employees
emps.LoadAll
 

 

 

 

Employees.FetchAll();
or sorted:
GridView1.DataSource =
Employees.FetchAll(SubSonic.OrderBy.Asc(Employees.Columns.LastName));
or in a collection:
EmployeesCollection products = new ProductCollection();
Employees.OrderByAsc(Employees.Columns.LastName);
Employees.Load();

 

Retrieving a single record
Dim emps As New Employees
emps.LoadByPrimaryKey(EmpID)
   

Employees employees = new Employees(id);
or:
Employees employees = Employees.FetchByID(id);
or:
Employees employees = new Product(Product.Columns.LastName, "Chai");

 

Adding a record
Dim emps As New Employees

emps.AddNew()
emps.LastName = "Smith"
emps.HireDate = Now
emps.Save()

'return new key value
EmpID = emps.ID
 

   

Dim emps As New Employees

emps.LastName = "Smith"
emps.HireDate = Now
emps.Save()

'return new key value
EmpID = emps.EM_ID
 

 

Editing a record
 

Dim emps As New Employees

emps.LoadByPrimaryKey(EmpID)
emps.LastName = "Smith"
emps.HireDate = Now
emps.Save()

 

  Dim emps As New Employees (key value)

emps.LastName = "Smith"
emps.HireDate = Now
emps.Save()

 

Deleting a record

 

Dim emps As New Employees

emps.LoadByPrimaryKey(EmpID)
emps.MarkAsDeleted()
emps.Save()

 

  Employees.Destroy(key value)
More complex query: select top 10 firstname, lastname from employees where salary > 1000 order by lastname asc

 

Dim emps As New Employees

With emps

.Query.Top = 10 .Query.AddResultColumn(.ColumnNames.firstname)
.Query.AddResultColumn(.ColumnNames.lastname) 
.Where.salary.Value = "1000"
.Where.salary.Operator =  WhereParameter.Operand.GreaterThan
.Query.AddOrderBy(.ColumnNames.lastname, WhereParameter.Dir.DESC)

End With

emps.Load()
GridView1.DataSource = emps.defaultview

 

  dim q as New SubSonic.Query(Employees.TableName)

q.top = "10"
q.SelectList = Employees.Columns.firstname + ", " +
Employees.Columns.lastname
q.AddWhere(employees.Columns.salary,
SubSonic.Comparison.GreaterThan, 1000);
q.OrderBy = SubSonic.OrderBy.Asc(Employees.Columns.lastname)

GridView1.DataSource = q.ExecuteReader()

 

Strengths / Weaknesses:

dOOdads

The good:

- has been around for a while
- has support for a large amount of databases
- has super easy aliassing built into it through the user of MyGeneration
- source in C# and VB.Net
- simplest framework of the lot (even I understood some of it :P)
- active support forum
- has a silly name :)

The bad:

- no active development at this time
- no templates support for dynamic SQL from MyGeneration itself
 
Subsonic

The good:

- least amount of code to do stuff
- build providers can mean: almost zero todo to get it working
- very rapid development of the framework
- free helpers:
    - auditing (created by, created on, modified by, modified when)
    - scaffolding (control using subsonic)
    - html report of tables
- it feels "smart"

The bad:

- it hasn't been around for very long
- very rapid development of the framework
- bombs on database tables with spaces in them amongst other things.

Castle Active Record

The good:

- it's built around the NHibernate engine
- it has support for the Hibernate query language
- it has a built in validation framework
- tables can be created from the classes
- it has support for joins

The bad:

- it's built around the NHibernate engine
- it's a probably a lot more complex then the other 2

Conclusion

I myself have used dOOdads with a number of projects and was very pleased with it's performance and it's easy of use and speed to set up.
For another project I used SubSonic and I was even more pleased with it's syntax + being able to use asp.net pages to generate te classes was a big plus for me.

Allthough it's possible to generate dOOdads classes through the command line I never got that far into MyGeneration to pull that off.
For me I'll be going for SubSonic for my future projects.

With dOOdads as a backup ORM. 

PS. If anyone has a very easy to set up ORM which he / she thinks is better then the ones in this comparison please let me know :)

Comments

# re: SubSonic v1 (ActionPack) vs dOOdads vs Castle ActiveRecord

Tuesday, May 08, 2007 11:51 PM by Patrick Wellink

Have you ever tried the same with EntitySpaces ?

# re: SubSonic v1 (ActionPack) vs dOOdads vs Castle ActiveRecord

Thursday, May 10, 2007 3:23 AM by Mischa Kroon

No haven't tried the same in Entityspaces, but from the examples I think it will probably be more verbose on the simple statements.

Or at least as verbose :)

And offcourse it costs money which means convincing someone in the organisation to shell out some cash for it :(

# re: SubSonic v1 (ActionPack) vs dOOdads vs Castle ActiveRecord

Sunday, May 20, 2007 12:11 PM by Rob Conery

"The bad:

- it hasn't been around for very long

- very rapid development of the framework

- bombs on database tables with spaces in them amongst other things."

Not sure how you factor in the length of time here :) though I think I know what you mean. You do need to consider, however, that we have some pretty brilliant people on this project (Phil Haack, Eric Kemp, Jon Galloway, Scot Watermasysk). Not trying to sound defensive :) but these guys are nails so it doesn't take them so long :).

Also - you can use regex to fix up the naming things (if you're compelled to use spaces for some odd reason).  In terms of "other things" can you be more specific? I'm always interested to know if anything flops so i can fix.

I know you mentioned you used 1.0.6 for this - check out our latest (2.0.1) it's miles ahead of the old one.

Thanks for the write up! Much appreciated :).

# re: SubSonic v1 (ActionPack) vs dOOdads vs Castle ActiveRecord

Monday, May 21, 2007 1:58 AM by Mischa Kroon

The problem with not being around for too long in this case is that it doesn't yet provide a platform which is set in stone.

There is still a lot of movement in the framework and v1 has other things then v2 etc.

# http://mygenerationsoftware.com/phpbb2/viewtopic.php?t=2787

Monday, May 21, 2007 2:29 AM by TrackBack

# re: SubSonic v1 (ActionPack) vs dOOdads vs Castle ActiveRecord

Tuesday, June 19, 2007 10:39 AM by chernics

I agree with you: been using SubSonic for several weeks. Been more than impressed; I believe this is the future of DB-driven software development...

# re: SubSonic v1 (ActionPack) vs dOOdads vs Castle ActiveRecord

Sunday, June 24, 2007 1:47 AM by Maruis Marais

Have you tried the Active Writer DSL for Active Record? (www.altinoren.com/activewriter). That will probably reduce the complexity of Castle Active Record for you. I've also looked at Subsonic and found it to be a nice framework. But in my opinion I still prefer Active Record. Maybe it is because the community is more active around Active Record. The other swaying factor is the proper MVC web framework in MonoRail that you get as part of the tools stack from Castle.

# re: SubSonic v1 (ActionPack) vs dOOdads vs Castle ActiveRecord

Monday, July 23, 2007 1:35 AM by Fejk

What a lame reply to Rob's post... Seriously, you want it "set in stone"? :) Then you should choose d00dads because its dead and completely set in stone!

Thanks anyway. SubSonic it is!

# re: SubSonic v1 (ActionPack) vs dOOdads vs Castle ActiveRecord

Friday, July 27, 2007 4:36 PM by Mischa Kroon

Fejk: How nice of you to call this a lame reply :)

While I thought I just wrote up a unbiased comparison...

# re: SubSonic v1 (ActionPack) vs dOOdads vs Castle ActiveRecord

Tuesday, May 06, 2008 4:55 AM by EDEL

ARE YOU USED XPO FROM DEVEXPRESS, ITS GREAT

Leave a Comment

(required) 
(required) 
(optional)
(required)