Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

C# DAL Method Code Generator

0.00/5 (No votes)
19 May 2008 1  
Generates C# data access layer method code for SQL Server stored procedures
Click to enlarge

Introduction

DAL Method Generator is a simple utility to generate data access layer methods in C# for SQL Server stored procedures. Have you ever written too many data access layer methods in C# to connect to SQL server stored procedures? This utility could save your effort using few clicks.

Using the Utility

C# DAL Method Generator is written using C# and you will require .NET Framework 2.0 to execute.

To use the utility, just invoke the EXE, which should open the Connect to SQL Server dialog below. It uses Windows authentication to connect to the SQL Server. Future work includes connecting to various other data stores like Oracle, etc. with other authentication as well.

Sample Image - maximum width is 600 pixels

Once connected to the server, you can drill down to see the databases and stored procedures for which you have permission.

Sample Image - maximum width is 600 pixels

To select all the stored procedures in a database, right click-on the node "Stored Procedures" and click "Add all Stored Procs to List". To add selected stored procedures, right click on them and choose, "Add to List". Selected stored procedures will appear on the right pane. Provide the method name for the C# method, by default the system uses the stored procedure name only. Also choose the return type for the method. By default, all methods generated return void.

Click to enlarge

To generate C# DAL methods, click on File -> Generate Code or the Generate Code Tool bar item. The code will be generated as below:

Click to enlarge

Points of Interest

I would like to extend it further to generate C# business entity, DAL method, basic CRUD stored procedures for the business entity based on table definitions and also to support other data stores.

History

  • 19th May, 2008: Initial post

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here