views:

651

answers:

7

I have a sql database and I want to create a class for each table. I think a tool exists that allows me to extract information from a sql database and transform it into classes like "DataTable" or "DataRow". Afterwards, I could use those object in dataset.

A: 

Try SubSonic

Josh
A: 

Maybe T4 (Text Template Transformation Toolkit) ist your friend...

Oliver
A: 

How about good old Linq? Start here.

jinsungy
+2  A: 

Instead of Data Table and Data sets you can use your own objects to represent data in your applications and to do so you can use some persistence frameworks and OR mappers (object relational mappers).For example you can use "Linq to Sql","Microsoft Entity framework" or NHibernate.

There are some code generation tools that let you generate code for these frameworks.

MyGeneration and CodeSmith as two of them that I know.

Beatles1692
I should go with LINQ, new for me.. nice challenge!
oL
+1  A: 

There is a whole world of tools out there that do things like this. It's called ORM. Josh mentioned Subsonic, which is a great free tool. There is also the Entity Framework which is part of Visual Studio 2008 SP1. If you would like an even better tool, the one I suggest you use is LLBLGen.

Hope this helps!

Artel
A: 

We are moving in the direction of Entity Framework, but we are taking our time because we dont find EF ready for prime time and Linq2Sql is more or less a poor mans/hobbyists ORM tool. At present we use a combination of a custom homegrown framework (The Kinetic Framework) and Fluent NHibernate.

xximjasonxx
A: 

An option if you want to write your own code generator would be to use SMO objects if you are using MS Sql Server 2005/2008 and pull the information out of the Table/Stored Procedure objects.

Kane