Active Record Or LINQ with IronRuby...?

Hi,

In my learning process, i am confused with the Advantages of ORM like "
ActiveRecord" and “Linq to SQL”

I would like to know… what majority developers think on this point.

Is it worth to go with LINQ to take full advantages or Get use to
ActiveRecord / Data Mapper for a proven ORM option.

Thanks

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 :slight_smile: 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]

Thanks Ivan for the excellent guidance.

You helped me move ahead, but i am still in confused stage in choosing
the right ORM.

Perhaps your book will explain more on this.

I think i should accept your idea to go SubSonic Way, since Subsonic
understands Active Record much better and its a straight implementation
of Active Record for .Net. Thats what i have heard, i am not too sure.

Refer this new blog here by Rob Conery…
http://blog.wekeroad.com/2008/03/11/subsonic-21-beta-2-available-now/#comments

Rob Conery answers…
Linq To SubSonic is in the works as we speak…

This sounds good enough.

Lets see, what more opinions we get here. Still enough time to decide.

Your expert guidance is always welcomed.

In my book I will use the ActiveRecord from Rails for most of the
examples
because it will be the most well-known and I suspect the one where most
developers are curious about. I will show how to leverage some of the
other
ORM’s to show that there are other options available.

I think SubSonic is a safe option, it is endorsed by Microsoft and won’t
go
away anytime soon. I’m not that familiar with SubSonic yet but from what
I’ve seen, it’s fairly easy to get started with. I don’t know if it will
work with IronRuby because I haven’t tried that. It’s something I have
planned to look at next week.

On Fri, Mar 14, 2008 at 9:37 PM, Rahil K. [email protected]

Hi,

Here’s a list of LINQ providers. LINQ to Everything

http://blogs.msdn.com/charlie/archive/2008/02/28/link-to-everything-a-list-of-linq-providers.aspx

LINQ Providers

* LINQ to Amazon
* LINQ to Active Directory
* LINQ to Bindable Sources (SyncLINQ)
* LINQ over C# project
* LINQ to CRM
* LINQ To Geo - Language Integrated Query for Geospatial Data
* LINQ to Excel
* LINQ to Expressions (MetaLinq)
* LINQ Extender (Toolkit for building LINQ Providers)
* LINQ to Flickr
* LINQ to Google
* LINQ to Indexes (LINQ and i40)
* LINQ to IQueryable (Matt Warren on Providers)
* LINQ to JSON
* LINQ to LDAP
* LINQ to NHibernate
* LINQ to JavaScript
* LINQ to Lucene
* LINQ to Metaweb(freebase)
* LINQ to MySQL, Oracle and PostgreSql
* LINQ to RDF Files
* LINQ to Sharepoint
* LINQ to SimpleDB
* LINQ to Streams
* LINQ to WebQueries
* LINQ to WMI
      o http://tomasp.net/blog/linq-expand.aspx
      o http://tomasp.net/blog/linq-expand-update.aspx
* LINQ to XtraGrid

This might help you in your decision

Hope this helps

SoftMind

Ivan Porto C. wrote:

In my book I will use the ActiveRecord from Rails for most of the
examples


Dear Ivan,

You mean to say you will be using ActiveRecord with IronRuby…?

Will Active Record work only with IronRuby on Rails or within Asp.Net
webforms and Asp.Net as Well…?

Which database are you using in your book. I mean MySQL / SQLite or SQL
2005…?

You have just raised my expectations with smile.

Because IronRuby is an implementation of the Ruby language you will be
able
to use ActiveRecord with anything.
I want to note again that there won’t be a thing like IronRuby on Rails.
The
rails framework will just run on IronRuby just like it now runs on CRuby
and
JRuby.

The database I’m using is irrelevant when I’m using ActiveRecord as long
as
I don’t set indexes it should run on sqlite as well for example.

hth
Ivan

On Fri, Mar 14, 2008 at 10:13 PM, Softmind T.
[email protected]

Hi Ivan,

I still have my doubts about smooth functioning of SQL Server 2005 with
Active Record.

I have heard several complains about SQL Driver 2005 not efficient as it
should be. MySql/Sqlite etc are working great with Active Record.

I just thought to invite your attention regarding this, since SQL 2005
will be the first priority Database for IronRuby.

Pl. investigate more in this segment.

Softmind T.:

I still have my doubts about smooth functioning of SQL Server 2005 with
Active Record.

I have heard several complains about SQL Driver 2005 not efficient as
it should be. MySql/Sqlite etc are working great with Active Record.

The SQL Server team is investigating providing support for SQL Server
via ActiveRecord and other ORMs. To be clear, they will be driving
this once we get ActiveRecord to the point where they can start
investigating how they will provide support for SQL Server.

Thanks,
-John

And as pointed out in the reply’s a few missing ones on the list.

LINQ to Entities,

(and the ones prebuilt in)
LINQ to XML
LINQ to SQL
and the in memory LINQ

PLINQ in the parallel platform ctp

LINQ to XSD has showed back up also.

Sure I am missing about 10 more just can’t think of them at 4 am in the
morning:)

Douglas


From: “Softmind T.” [email protected]
Sent: Friday, March 14, 2008 4:03 AM
To: [email protected]
Subject: Re: [Ironruby-core] Active Record Or LINQ with IronRuby…?

Ivan Porto C. wrote:

I want to note again that there won’t be a thing like IronRuby on Rails.
The
rails framework will just run on IronRuby just like it now runs on CRuby
and
JRuby.


Hello Ivan,

Pl. guide me. I’m still confused about the exact working on Ruby on
Rails on .Net platform. You say that… there wont be a thing like
IronRuby on Rails… Then how i will be able to run Rails on .Net
platform.

You mean to say that i can simply paste the codes, currently developed
in Rails via Netbeans into VS2008 and that will run easily, without
alterations.

This seems to be difficult to digest. Can you make clear, what
modifications will be required to existing Ruby on Rails code to make it
work on VS2008 or Sapphire Steel or any IDE that supports .Net DLR.

Sorry for the trouble.

WebReservoir

Web R.:

You mean to say that i can simply paste the codes, currently developed
in Rails via Netbeans into VS2008 and that will run easily, without
alterations.

Yes.

-John

John L. (DLR) wrote:

Web R.:

You mean to say that i can simply paste the codes, currently developed
in Rails via Netbeans into VS2008 and that will run easily, without
alterations.

Yes.

-John


Hey John,

I have million smiles to share with Ironruby Team.

You just made my day.

WebReservoir.

I think DLR will be the next big programming venue.

On Thu, Mar 20, 2008 at 10:05 AM, Web R. [email protected]

John L. (DLR) wrote:

Softmind T.:

I still have my doubts about smooth functioning of SQL Server 2005 with
Active Record.

I have heard several complains about SQL Driver 2005 not efficient as
it should be. MySql/Sqlite etc are working great with Active Record.

The SQL Server team is investigating providing support for SQL Server
via ActiveRecord and other ORMs. To be clear, they will be driving
this once we get ActiveRecord to the point where they can start
investigating how they will provide support for SQL Server.

Thanks,
-John

Hi,

I have been using Ruby to integrate with large complex legacy SQLServer
databases for over 2 years now and it isn’t that hard.

  1. Use Dr Nic’s compositekeys http://compositekeys.rubyforge.org/
  2. Use Rahoul B.'s sql_server.rb for stored procedure support

Now that I have dabbled with IronPython and LInQ I too am curious about
the best approach for data_access/ORM with so many possibilities opening
up.

Linq2ActiveRecord provider
or
Add XML and collection mapping to ActiveRecord
(I think XML can be fudged with a couple of pseudo tables related)
or
List Comprehension or Generators

If a Linq2ActiveRecord provider is possible that might be the best of
all worlds (if performance doesn’t rear it’s ugly head). Dr. Nic also
has something called Magic Modes to reverse engineer an entire database
into ActiveRecord models and other cool stuff.

There must be some synergy possible here.

Best,
Carl

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs