views:

161

answers:

4

I don't want to write stored procedures any more (not unless I have to), so should I use out of the box Linq-to-SQL or the Castle ActiveRecord implementation?

I understand there are some differences between the two as mentioned here on Stackoverflow

A: 

Linq-to-SQL seems to be loosing ground due to Entity Framework. Since EF integrates nicely with many new and upcoming MS technologies, you probably would not regret using EF. Not sure how it fares in comparison with Casle thuogh.

Andreas
EF has a number of very annoying parts in the current incarnation.
Paddy
+1  A: 

Use Linq to SQL - its very easy to get started and there is a lot of documentation out there for it. In addition you don't need to take any dependencies on anything outside the box, which will save you time.

mcintyre321
The designer seems to make it easy to get started too, whereas I'll need to code up all my classes with Castle AR.
Naeem Sarfraz
Not really. There's a designer for ActiveRecord called ActiveWriter. It is not recommended to use a designer in a real project though
Krzysztof Koźmic
@Krzysztof Koźmic - What's a 'real' project?
Paddy
Designers tend not to scale well as the number of tables grow and they tend not to support edge cases very well, and edge cases are all too common in reality. LinqToSql's designer has its own set of troublesome issues, like not being able to easily sync up with changes in the database.
Michael Maddox
@Naeem: Castle AR supports the same sort of designers and code generation that LinqToSql supports. You are certainly welcome to code up your classes, but that's a choice, not a requirement.
Michael Maddox
When the db schema changes I regenerate the dbml file and run a transformation script against it rather than make changes with the designer. Or at least I did until I learnt NH.
mcintyre321
@PaddyTry to use a designer when you have 100 big tables, or even 50.Try to use it with version control...
Krzysztof Koźmic
+3  A: 

I would say try both, and see which suits your needs best. Asking questions like these you will most likely get another answer - "which one I like better". There's no one size fits all solution, and with little details you have given it's hard to help you really.

Notice that ActiveRecord uses NHibernate underneath, which is a much more powerful ORM than L2S, so if you intend your project to grow, it's flexibility and maturity may be helpful in the long run.

Krzysztof Koźmic
Naeem Sarfraz
I'm not 100% what you mean by that. You'll end up writing more code to deal with Linq to SQL in the long run because with AR (NHibernate underneath it) you can bend your entities to be almost anything you need them to be for your model. L2S maps clasess to tables 1-1 so you'll have to map and convert them later on, which means more code you have to write.
Krzysztof Koźmic
@Naeem: Which code generators have you tried for Castle ActiveRecord?
Michael Maddox
@Michael, sorry I wasn't clear. We haven't tried Active Record seriously yet. I've coded up a couple of tables just to get started but I never got further than that.
Naeem Sarfraz
+2  A: 

I'm not sure why you happen to be choosing between those two only?

LinqToSql currently has a better Linq provider than NHibernate.

Castle ActiveRecord is based on NHibernate. NHibernate is a lot more feature rich than LinqToSql and features are being added much more quickly to NHibernate.

Depending on the complexity of your domain, data model, and requirements, you may be forced to go with NHibernate at some point because LinqToSql just can't do what you need it to do (you haven't specified what kind of environment and requirements you have, which makes a big difference).

It can be difficult/expensive to transition from one ORM to another, so it is important to choose wisely.

There are some situations where I would recommend LinqToSql over Castle ActiveRecord, but they are few and far between. Generally, Castle ActiveRecord is much more likely to work in your situation.

Michael Maddox
The targetted apps are usually enterprise-wide systems that are built with ASP.NET. We're moving from 2.0 to 3.5 and have been using a traditional DAL built using ADO.NET. We need to move away from that.
Naeem Sarfraz
@Naeem: I would start with Castle ActiveRecord if I were you.
Michael Maddox