All of them have their advantages and disadvantages.
Linq2Sql only works for MS Sql Server, but gives you a graphical
designer
for your objects. It implements a unit of work which reduces the number
of
database calls.
It doesn’t however support many-to-many relations, and it depends how
much
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
fetches
instead of spans (which is the way it was done in ObjectSpaces).
Linq2Sql
allows the use of stored procedures which is one way you could
circumvent
performance bottlenecks.
ActiveRecord, I assume you’re talking about the Rails implementation of
ActiveRecord. It offers more flexibility than Linq2Sql because supports
a
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
(ab)use
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
mysql,
postgres and sqlite3. Because it’s less opinionated you can use it with
legacy databases where ActiveRecord from rails makes this hard.
DataMapper
uses the identity map pattern which allows for reuse of objects within
the
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
properties.
In combination with IronRuby I, personally, would probably not use any
of
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
situation
where ActiveRecord gives you the best options for different
infrastructures.
Linq2Sql gives you the best SqlServer support (and I guess that it would
be
the fastest too). DataMapper gives you some options with legacy
databases
and I imagine it wouldn’t be too hard to implement a ms sql driver, at
which
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
with
that same syntax.
I think LINQ is valuable regardless of which ORM you use because of the
easy
access you have for performing complex manipulations on collections,
although it comes at a certain performance cost. Seen as you’re using
Ruby
I wouldn’t worry too much about the performance cost of LINQ unless you
have
actual performance problems at which point you can optimize the code
that is
responsible for the bottleneck.
The opinions above are my own opinions, other people most likely have
different ideas around this subject.
Hope this helps,
Ivan
On Fri, Mar 14, 2008 at 8:19 PM, Rahil K. [email protected]