All of them have their advantages and disadvantages.
Linq2Sql only works for MS Sql Server, but gives you a graphical
for your objects. It implements a unit of work which reduces the number
It doesn’t however support many-to-many relations, and it depends how
value you give to highly performant sql. Some of the sql it generates is
quite smart, I just think it’s a pity they chose to use hierarchical
instead of spans (which is the way it was done in ObjectSpaces).
allows the use of stored procedures which is one way you could
ActiveRecord, I assume you’re talking about the Rails implementation of
ActiveRecord. It offers more flexibility than Linq2Sql because supports
multitude of databases. The sql it generates is also not always the most
performant but like Linq2Sql it will do just fine, it allows for you to
optimize your queries by writing sql yourself or you could possible
that feature to execute stored procedures on sql server.
From the 3 choices you’ve given DataMapper is the most flexible, it is less
opinionated than ActiveRecord but doesn’t support as many databases as
ActiveRecord does, for example it doesn’t support ms sql server but
postgres and sqlite3. Because it’s less opinionated you can use it with
legacy databases where ActiveRecord from rails makes this hard.
uses the identity map pattern which allows for reuse of objects within
same session, where ActiveRecord does not AFAIK.
Both ActiveRecord and DataMapper support many-to-many relations and
datamapper allows for more granular control over the visibility of the
In combination with IronRuby I, personally, would probably not use any
these in my own applications But rather use one of the other existing
.NET ORM’s like NHibernate, SubSonic, LLBLGen, LightSpeed, …
But from the 3 choices you gave above I’d say it depends on the
where ActiveRecord gives you the best options for different
Linq2Sql gives you the best SqlServer support (and I guess that it would
the fastest too). DataMapper gives you some options with legacy
and I imagine it wouldn’t be too hard to implement a ms sql driver, at
point it becomes a more attractive option than ActiveRecord IMHO.
And lastly LINQ and Linq2Sql are 2 different things. LINQ allows you to
query in-memory collections and Linq2Sql allows you to query a database
that same syntax.
I think LINQ is valuable regardless of which ORM you use because of the
access you have for performing complex manipulations on collections,
although it comes at a certain performance cost. Seen as you’re using
I wouldn’t worry too much about the performance cost of LINQ unless you
actual performance problems at which point you can optimize the code
responsible for the bottleneck.
The opinions above are my own opinions, other people most likely have
different ideas around this subject.
Hope this helps,
On Fri, Mar 14, 2008 at 8:19 PM, Rahil K. [email protected]