Generating Business Objects

March 18th, 2008 admin Posted in c#, development, sql |

Once I was developing an application which was accessing a database. So the database had a number of tables (more than 10) for which I had to create business objects. Almost each table TableName had to have a class CTableName containing every field of the table. And also for every class I had to create a collection class CTableNameCollection. I didn't feel like doing that manually so I created an SQL script.

The script has its parameters:

SET @BOPrefix = 'C' - - Prefix of the business object
SET @TablePrefix = 'dt_' - - Table prefix if it has any
SET @TableName = 'dt_Customer' -- Table for wich we need to generate the business object
SET @CurrentNamespace = 'BusinessObjects' - - A namespace in which we are gonna create the business object
SET @ReplacePKWithID = 1 - - In case we have a primary key field named CustomerID but in the business oject we wanna replace it with 'ID'
SET @IDPropertyName = 'ID' - - The name of the field we are gonna use to rename ID column in the business object

I have attached the script to this post.

files: Generating Business Objects

Leave a Reply

You must be logged in to post a comment.