Linq to SQL vs Nhibernate or Castle ActiveRecord
-
Does Linq to sql deprecate Nhibernate and Active record? I have a client that wants to use active record, and It looks like the last update to it was 10 months ago. This concerns me a bit. It also seems to be much more work to get ActiveRecord mapped to my database then it does for Linq to Sql. I'm using Visual Studio 2008. Is there a Good way to generate the mappings and classes for active record? I don't want to spend 3 days doing it manually. I need some more information so that I have a good argument as to why Linq to Sql is superior and should be used instead.
-
Does Linq to sql deprecate Nhibernate and Active record? I have a client that wants to use active record, and It looks like the last update to it was 10 months ago. This concerns me a bit. It also seems to be much more work to get ActiveRecord mapped to my database then it does for Linq to Sql. I'm using Visual Studio 2008. Is there a Good way to generate the mappings and classes for active record? I don't want to spend 3 days doing it manually. I need some more information so that I have a good argument as to why Linq to Sql is superior and should be used instead.
As no-one has replied I'll give you a few ideas. I'll qualify this by saying I don't use NHibernate or ActiveRecord and am not familiar with them. Why I use LINQ to SQL: 1. Easy to learn and use 2. Good performance, lightweight objects 3. Use same LINQ syntax for multiple datasources e.g. not just SQL, there is LINQ to XML, Objects, Entities.. 4. Easy to read code For example I noticed this sample code on the NHibernate site just now:
//finds a list of People with the same 'Name' property
ICriteria criteria = session.CreateCriteria(typeof(Person));
criteria.SetProjection(Projections.ProjectionList()
.Add(Projections.Max("Id"))
.Add(Projections.GroupProperty("Name")))
.Add(Restrictions.Gt(Projections.Count("Name"), 1));
IList results = criteria.List();Not particularly easy to read. Here's the LINQ to SQL equivalent:
var results = from p in db.People
where (from p2 in db.People
group p2.Name by p2.Name into g
where g.Count() > 1
select g.Key).Contains(p.Name)
select new { p.ID, p.Name };The LINQ to SQL query is a lot closer to the SQL query structure and is easier to read.
'Howard
-
As no-one has replied I'll give you a few ideas. I'll qualify this by saying I don't use NHibernate or ActiveRecord and am not familiar with them. Why I use LINQ to SQL: 1. Easy to learn and use 2. Good performance, lightweight objects 3. Use same LINQ syntax for multiple datasources e.g. not just SQL, there is LINQ to XML, Objects, Entities.. 4. Easy to read code For example I noticed this sample code on the NHibernate site just now:
//finds a list of People with the same 'Name' property
ICriteria criteria = session.CreateCriteria(typeof(Person));
criteria.SetProjection(Projections.ProjectionList()
.Add(Projections.Max("Id"))
.Add(Projections.GroupProperty("Name")))
.Add(Restrictions.Gt(Projections.Count("Name"), 1));
IList results = criteria.List();Not particularly easy to read. Here's the LINQ to SQL equivalent:
var results = from p in db.People
where (from p2 in db.People
group p2.Name by p2.Name into g
where g.Count() > 1
select g.Key).Contains(p.Name)
select new { p.ID, p.Name };The LINQ to SQL query is a lot closer to the SQL query structure and is easier to read.
'Howard
NHibernate has linq support so you can very well do the same in NHibernate... NHibernate is way more powerful than Linq to SQL when it comes to features. Actually, none of your arguments can be used against NHibernate since NH has more lightweight objects and in many cases better SQL generation.