views:

994

answers:

7

I am using Visual Studio 2005, Sql Server 2005, C#, ADO.NET. We have a very large database and routinely adding new stored procedures. I am tired of writing the C# wrapper code for these stored procedures, seems like there should be some simple utility or Add In that would allow me to simply point to a stored procedure and generate some generic C# code.

I am not looking for some big ORM or data access layer framework. The company I am doing this for is not interested in moving to something like that right now. Just wanting something to take the grunt work out of writing the C# wrappers around stored procedures. Again, prefer that we do not have to include in other 3rd party libraries, etc.

Any ideas?

+1  A: 

Take a look at SP C# Code Generator.

You can also check out this old CodeProject article.

Vadim
+2  A: 

Hello

I have used "Code Smith". Worked like a charm.

A free trial is available, and if you automate then process, then it pays for itself quite fast..

Take a look here: http://www.codesmithtools.com/?s=g1&gclid=COWj27vu%5FZwCFVATzAod2GIxaw

Heiko Hatzfeld
+1 for beating me to it...
klabranche
There is also the freeware version of codesmith 2.6 that may be enough to do the trick for just SP's.
klabranche
+1  A: 

You could also use T4 templates. It's part of VS 2008 but you can download it for 2005 using the GAT toolkit.

Some helpful links:

Hanselman blog entry on T4

http://www.olegsych.com/2008/01/how-to-use-t4-to-generate-crud-stored-procedures/

http://www.buildmotion.com/buildmotion-blog/09-06-15/T4_Templates_for_Stored_Procedures.aspx

klabranche
A: 

You may want to keep an eye on AtomWeaver (http://www.atomweaver.com), a flexible code generator that also implements the new ABSE (Atom-Based Software Engineering, http://www.abse.info) model-driven development paradigm.

Well, it's still in development phase but launch is expected at the end of the year...

Rui Curado
A: 

Check out www.mygenerationsoftware.com - a free .NET code generation tool with many templates to download and use for free. Should have what you are looking for. This is a free open source project that competes with codesmith.

Justin
A: 

The only answer to all questions regarding Stored Procedure Generation is T4S Stored Procedure Generator (www.tools4sql.net). This is very interesting & advance stored procedure generator tool. check this out atleast once.

Thank you...

Rivel

Rivel
A: 

I have evaluated many ORM modellers and code generators over the years, none of them gave me the code I wanted. Over the last few years in my spare time I have created my own stored procedure and C# code generator.

The generator is very intuitive to use and generates CRUD stored procedures, Data Components, Business components and Business Entities. The generated code uses SqlDataReaders for it's data retrieval and no reflection.

It will even generate a n-Unit test project.

Caching support is available through business objects as well as IoC for Data Components.

Performance benchmarks comparing it to the ADO.NET Entity Framework and Linq to SQL can be found on the site.

FrameworkGen can be found here http://www.elencysolutions.co.uk

CroweMan
wow, very nice from just looking at your website and what it does. I may try to evaluate later. This was really what I was looking for at the time.
Ron