tags:

views:

299

answers:

6

Ok, I am asking this question because I am totally confused. I used to use normal approach to access databases from C#(I mean by using SQLConnection, OracleConnection, SQLCommand, executequery etc.). Then I heard about ADO.NET, ORM and learned NHibernate(not a pro, but I can manage).

Recently I don't see any particular activities regarding NHibernate a lot. People around me who used to use NHibernate(and was a fan) are now moving to other methods.

So what is the most used database access method nowadays? How can I keep track of this changing trend?

+14  A: 

The most common methods are probably these:

  • LINQ to SQL
  • Entity Framework
  • ADO.NET directly
  • NHibernate
  • Other O/RMs.

All of them are still in use and they have different advantages and disadvantages. I think Microsoft are currently trying to encourage people to use the Entity Framework.

Mark Byers
+4  A: 

In my opinion, for rapid application development, using an ORM tool like LLBLGEN is the best solution. You can speed up the development progress dramatically.

DrakeVN
+8  A: 

There is only one way - ADO.NET for SQL Server. More particular, the Connection and Reader objects in there. Now, you may say there are things like Entity Framework - but interesting enough they are ABOVE the real access layer, using both access elements named before. Even DataSets are a higher layer (the data is read through a DataReader).

So what is the most used database access method nowadays?

I bet it STILL is datasets. The amount of uneducated following the drag and drop principle is IMHO still the majority, and this approach in visual studio leads to Datasets.

Professionals use an ORM of sorts. Entity Framework is pretty pushed now by people who mostly do not really know what an ORM can do it programmed properly. Right now my best bet is still NHibernate for a high quality layer.

TomTom
Not a bad answer save for the last paragraph. Entity Framework is used by those of us that realize there are different types of ORMs, each having unique strengths and weaknesses...so we chose Entity Framework for our application.
Justin Niessner
Not just 'uneducated' use of drag and drop, but there a a lot of existing systems out there written using ADO.NET and typed datasets and these are still being developed -- no one is going to refactor an entire system just to use newer ORM technology.
Dr Herbie
@Herbie: legacy code is a clear defense, right. @Justin - EF never was a decent ORM so far. There is hardly any strength in it compare to more mature offerings.
TomTom
+1  A: 

So, there are few technologies to access database in .NET. At first, this is ADO.NET. It is one 'true' access technology, because other (like NHibernate, LINQ2SQL, Entity Framework (they are all ORM)) uses ADO.NET to actually connect to database and execute commands against it. Of course, .NET provides other ways to interact with database, for example, importing some of COM interface, but they are not natural.

Also, tools that helps you communicate with database exists. It is ADO.NET extensions (like Enterprise Library Data access), and tools allows you to work with objects (named entities) which are natural for object-oriented runtime as .NET, but load and save that entities from the database. These tools named ORM (object-relational mapper), and modern tools are easy to use and nice.

STO
+1  A: 

I personally love Linq To Sql using CodeSmith to generate the entities, more specifically I think Plinqo has the most ease of extensibility. It allows you to separate all of Entity objects into separate files with an editable version and a generated one. This allows you to extend your DAL with as many helper functions that you need. it has a Visual Studio add-in that lets you regenerate all of your entities with just a click.

I normally to database first design, so I make my changes in the database, go to VS regenerate the entities, and then I can continue coding.

Regardless of what you choose, I think an important factor for an ORM is being able to configure it to meet your needs, there is no one size fits all.

BTW, I don't work for CodeSmith, I just use it :)

Jose
+1  A: 

well if i have to pick one, i would say entityframework that's the most generic way, linq to sql is being depricated in the future, nhibernate will be more and more in the future.

but the best advise is probably try to pick one for the whole team! even if it has downside they all have at some point or an other

Mptje