Click to See Complete Forum and Search --> : Auto Generation Database Accessor Methods


ShadowGopher
March 3rd, 2003, 10:39 AM
I'm not sure if this is even the right forum for this question. Using the tools provided with Visual Studio.Net, is there a way to create a class file from a database table where the SET and GET method accessors are automatically generated?

Here is what I'm trying to do. I have a third party rule engine that I'm using for data validation of our client's data that we import into our database. Since each rule needs to operate on one row of data, I'm creating a class for each table and accessor methods for each column within that table. Therefore, when the business users create their rules, they can refer to the lastname column in the employee table as Employee.LastName. I've got about 30 tables and a little over 300 columns. I prefer not to have to code every function by hand. It seems like an easy enough process to generate this type of class so I think somebody should have had this requirement before. Does anyone know of a way to automatically generate these classes, properties, and methods?

Thanks,
Mark Brown

pareshgh
March 3rd, 2003, 12:08 PM
I am not sure any of the VS.NET wizard directly does that. how ever you can create a form and put a datagrid
by that again you have to assign sqlcommand, datasource, databinding anyways...

another thing which reminds me ,
check out ,

1) other projects in Project creation in VS.NET IDE
2) take DataBase Project
check out and let me know if it works for u
;)

thanx
Paresh

ShadowGopher
March 4th, 2003, 08:14 AM
Thanks for the reply. I looked at the Database Project and unfortunately, it won't work. I have seen, in some other forums, where people have created some utilities to do this. However, I have been unable to contact any of them. I could write this myself but, I was hoping to not have to do that. I'm on a tight deadline as is. Has anyone here written a similar utility in C# because apparently there is no way to do this with the tools provided in VS.Net.

Thanks,
Mark Brown

pareshgh
March 4th, 2003, 10:46 AM
why don't you search for VS.NET Wizards that can be installed and does the simillar purpose. I remember I had downloaded some wizards (.viz or something) file and just invoking it helps and navigates the project creation. i think you need that..

-Paresh

WarWolf
March 6th, 2003, 06:30 AM
Had the same problem, it's a pain to make 300+ classes or interfaces. So i made my own program to generate the code, this program is made for MS Access my you can prb modify it to suit you.

ShadowGopher
March 6th, 2003, 10:55 AM
Thanks, WarWolf.
I just finished my own version of this utility yesterday. I have yet to test it though. I converted what someone else did in VB.Net and then cleaned it up for C#. However, the utility is only a command line program. I may yet use your utility as a model to add a user interface to my utility. I really appreciate your help. I'll try to upload my version to this thread when I've finished testing it.

Mark

pareshgh
March 6th, 2003, 11:47 AM
:D
shadow..
could you post the utility.. would like to see it.
apreciate it.

paresh

ShadowGopher
March 6th, 2003, 12:43 PM
Attached is the zip file of the utility. I've tested it to generate "*.cs" files. However, I haven't tested yet to see how those classes work yet. As I do some more testing, I may post some enhancements here. If anyone else enhances this, I'd appreciate seeing them.

Mark

pareshgh
March 6th, 2003, 01:30 PM
GREAT !!!
thanks