Database class?

Coming from PHP it’s common to have a simple class that makes talking to a database very easy. Do people use the same approach in .net, or do you have a class for say products, which handles all database communications for the products table?

So you are allowed to suggest gui designers but no one else is?

Don’t be silly wwb. Of course you can. I just didn’t pick up on what he’d actually asked for myself, until my last post. =/

What is the most common method?

I’m sorry, but this really depends on the individual firm. There’s also SqlClient, OdbcClient, SubSonic and many other third party way to this. Honestly, I’d say look at the all, and just choose the one that best suits you. Most modern firms have experience in just about all the major things. Off hand though, I’d probably say NHibernate is the way to go if you want the best chance of others to take over later.

Thanks for the replies so far.

I had never heard of linq before. I usually just communicate directly with SQL.

If I were developing a web app which may be managed by another developer in the future, is it likely that another developer would know linq and be able to take over?

What is the most common method? Creating your own classes per model or using something to do it for you?

I can’t believe I’m going to say this, but check out WebMatrix http://weblogs.asp.net/scottgu/archive/2010/07/06/introducing-webmatrix.aspx

At this point, if you have VS 2010, just jump directly to the EF, no need for linq2sql. They both have the same GUI designer, EF is alot more powerful at the end of the day.

First:

I’d start with learning how to use the LinqToSql designer. It’s a GUI tool that allows you to build your models interactively. It has it’s limitations though.

So you are allowed to suggest gui designers but no one else is?

Second: EF code first is here.

More important, there are some many little retarded things wrong with Linq2Sql whereas the EF is no harder to pick up that it makes no sense to even bother with Linq2Sql in this day and age.

I’m going to have to disagree with you slightly wwb. He asked about data classes, not gui’s. LinqToSql is much easier to implement without the gui, than the Entity Framework currently is. He wants easy to code classes. So let’s give him that. Once he needs more, he’ll move on like we all did.

The best LinqToSql class-only documentation is:

I’d start with learning how to use the LinqToSql designer. It’s a GUI tool that allows you to build your models interactively. It has it’s limitations though.

Once you move past that, you’ll want to look at the Entity Framework (also comes with VS). It’s more enterprise-oriented, has more options, and is more customizable.

Finally, take a look at NHibernate. It’s a third party solution, but it’s touted by the community as the best.

Hope that helps.