Click here to Skip to main content
Click here to Skip to main content

Code Generator for 3 Tier Architecture

, 10 Jun 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
Code Generator for 3 Tier architecture (for layers) & Stored Procedures (for CRUD operations) based on table design

Introduction

In this tip, we will try to understand how to generate code for tiered architecture automatically and generate stored procedures for CRUD operations automatically based on table schema. Through this tool, we will try to understand what are the different classes that are generated and what is the use of those classes and we will try to see how this tool helps us to save time at the time of coding. We will try to understand what kind of logic should go inside this tool.

This is a small tool for all my .NET friends to generate code automatically which saves time for coding, avoids redundant fields, follows similar names and data types, creates stored procedures for CRUD operations with similar fields which is similar to database table columns.

We can create project architecture easily within less time period and we can maintain all projects with unique structure.

Background

I found some issues or problems while creating projects, designing systems, creating stored projects.

  • Dissimilarity with field names and datatypes in Tables Columns, Procedures, Data Layers, Presentation Layers, etc.
  • No Uniform structure for project architecture, different developers follow different structures for coding within the same project.
  • Redundant fields, methods, functions and stored procedures to perform operation because of dissimilar naming conventions.
  • Consuming lot of time for coding to perform the same job like creating similar kind of logic and operations.

To solve the above problems, I have created this simple tool for code generation which is helpful and useful to programmers especially.

Using the Code

1. DB Mapping

This is DB Mapping window to select your SQL Servers from local machine or network, select database from that selected server, select tables from the selected database, select various conditions to generate the code based on user choice.

This is DB Mapping page to select your sql servers from local machine or from network, select database, select tables, select various operation for code operations

Step 1: The user can enter the server name or load server names from local machine or from network by clicking button S in server details section. Depending on server selection, enter the corresponding user id and password and click button load databases to load all the databases in that server.

Step 2: Select database from database details section, click on button Load Table to load tables.

Step 3: Select required tables for code generation from select table sections click on button Load Selected.

Step 4: Select choose option either Auto or Manually, Other Class either Same or Common, Property Class either Same or Common.

Step 5: Enter Project name without any spaces and click on button Add Class Names to Add/Edit Class information in grid.

Step 6: Based on the user preference, the Grid is loaded, i.e.:

Note

Choose option section: If Auto is selected, all check boxes are selected in Data Grid. If Manually is selected, all check boxes are unselected in Data Grid, then user can select required options from Data Grid.

Other Class section: If Same is selected, the OClassName will be same as TableName, i.e., all classes in business layer and data access layer will be generated separately. If Common is selected, all classes in business layer and data access layer will be generated in a single class.

Property Class section: If Same is selected, the Class Name will be same as TableName, i.e., all property classes in data layer will be generated separately. If Common is selected, all property classes in data layer will be generated in single class.

2. DB Query

This DB Query window will generate stored procedures based on the options selected by user. You can execute these queries from here to generate stored procedure in your selected database.

This based generates stored procedures based on the selected options, you can execute these queries from here to stored procedure in your selected database.

3. DB Base Classes

This DB Base Classes window will generate base classes for the project with predefined structure. You can add your own logic inside these base classes.

4. DB Classes

This DB Base Classes window will generate base classes for the project with predefined structure. You can add your own logic inside these base classes.

Points of Interest

While creating this tool, I learnt these interesting things:

  • How to find database servers from network
  • How to handle data grid with controls
  • How to create and use user defined components
  • How to handle different panels
  • How to dock controls in the window

History

  • 10th June, 2014: Initial version

I'll keep updates on this tool for any changes or improvements made.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Suresh Dasari's
Software Developer (Senior)
India India
Senior System Analyst with 6+ years of experience in requirement, analysis, design, development and execution of Web based applications with N-tier architecture using ASP.NET, C#.NET and SQL Server Technologies.
Follow on   LinkedIn

Comments and Discussions

 
GeneralSimilar type of application i found at below link with more options PinmemberMember 301549210-Jul-14 2:05 
QuestionMy Vote is 5 PinmemberRamu nunna13-Jun-14 20:04 
GeneralNice one !!! PinmemberPrashanthJagannath12-Jun-14 20:27 
GeneralRe: Nice one !!! PinmemberSuresh Dasari's13-Jun-14 9:50 
Questionwhere is the source? PinmemberThava Rajan11-Jun-14 4:13 
AnswerRe: where is the source? PinmemberSuresh Dasari's13-Jun-14 9:49 
GeneralMy vote of 2 PinprofessionalKornfeld Eliyahu Peter11-Jun-14 3:57 
GeneralRe: My vote of 2 PinmemberSuresh Dasari's13-Jun-14 9:45 
GeneralMy vote of 3 PinmemberKlaus Luedenscheidt10-Jun-14 20:18 
GeneralRe: My vote of 3 PinmemberSuresh Dasari's13-Jun-14 9:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141220.1 | Last Updated 10 Jun 2014
Article Copyright 2014 by Suresh Dasari's
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid