|
AspxCodeGen 4.0
AspxCodeGen 4.0 is a .NET 4.0 code generator. It generates C# or VB.NET Business Tier, Data Tier, and Dynamic SQL or Stored Procedure codes based on your
MS SQL Server database's Tables or Views. The generated code encapsulates CRUD (create, retrieve, update, delete) calls to the database so that any client (ASP.NET web forms, winforms, web services, etc)
may have access with a few lines of code, most of the time with just one (1) line of code.
Because everything else is generated for you, all you have to write, for most parts is just One line of code. See code examples below.
N-Tier Layer Approach
AspxCodeGen 4.0's generated code was built using the 3-tier (n-tier) architecture. A presentation tier (the client), middle tier (business objects), and the
data tier (data access objects). Although no web form or win form is generated as a presentation layer, classes (.cs or .vb) showing how to use the
generated middle tier objects are generated to show how easy it is to use/call an operation from a client. The client could be a web form (.aspx),
a win form, or a web service (.asmx), etc.
The middle tier encapsulates all calls to the data access objects (data tier) so that calling a CRUD (create, retrieve, update, delete) and other
operations are very easy and may only take one line of code for most parts. We made it even easier by generating and showing an example for each CRUD operation,
for each table in your database, so you just copy and paste a call from your chosen client (see code examples below).
The data tier encapsulates all calls to the database. These could be calls to Stored Procedures or Dynamic SQL. Stored Procedures or Dynamic SQL are also generated
so you don't have to worry about writing T-SQL commands.
The bottom line: All you have to code is the call from your client to the generated middle tier objects. For most parts, all you have to write is one line of
code. The best part is; we also provide you the exact syntax to call an operation, so all you need to do is copy and paste the generated code from our
examples. See code examples below.
For example you have a database table called "Categories", classes called CategoriesExample, Categories, and CategoriesDataLayer will be generated
as seen in the image above. All the examples on how to Select, Update, Delete, Insert, etc to your "Categories" table can be copied from the CategoriesExample class and pasted
to your client (web form, win form, web service, etc). And that's it, you don't have to write the middle tier objects, nor the data tier objects, nor the database objects
(T-SQL code: stored procedures, dynamic sql), they are generated for you.
[ back to top ]
Code Examples
The code examples below are based on a "Categories" database table which AspxCodeGen 4.0 generated code for. These examples are copied from a
class called CategoriesExample (.cs or .vb) generated by AspxCodeGen 4.0. This is how simple it is to call the middle tier objects from your client
(web form, win form, web service, etc.). Note: You can do more operations than what's being shown below.
Because everything else is generated for you, all you have to write is the following code. We made it even easier, we also generate
examples for each operation, so all you need to do is copy and paste code like the ones showing below.
Select Everything: E.g. You can assign allCategories to a GridView control or use it in a foreach loop.
C#:
var allCategories = Categories.SelectAll();
VB:
Dim allCategories = Categories.SelectAll()
Sort Ascending By Property: E.g. Add this line of code to the Select Everything code shown above.
C#:
allCategories.Sort(Categories.ByCategoryName);
VB:
allCategories.Sort(Categories.ByCategoryName)
Sort Descending By Property: E.g. Add these lines of code to the Select Everything code shown above.
C#:
allCategories.Sort(Categories.ByDescription);
allCategories.Reverse();
VB:
allCategories.Sort(Categories.ByDescription)
allCategories.Reverse()
Select a Record By Primary Key: E.g. One (1) here is the primary key.
C#:
var cat = Categories.SelectByPrimaryKey(1);
VB:
Dim cat = Categories.SelectByPrimaryKey(1)
Delete a Record By Primary Key: E.g. One (1) here is the primary key.
C#:
Categories.Delete(1);
VB:
Categories.Delete(1)
Insert a New Record: E.g. Upon insertion you can retrieve the inserted primary key*.
C#:
Categories objCategories = new Categories();
objCategories.CategoryName = "Shoes";
objCategories.Description = "Something you wear on your foot";
int newlyCreatedPrimaryKey = objCategories.Insert();
VB:
Dim objCategories As New Categories()
objCategories.CategoryName = "Shoes"
objCategories.Description = "Something you wear on your foot"
Dim newlyCreatedPrimaryKey As Integer = objCategories.Insert()
Update an Existing Record By Primary Key: E.g. One (1) here is the primary key.
C#:
Categories objCategories = new Categories();
objCategories.CategoryID = 1;
objCategories.CategoryName = "Shoes";
objCategories.Description = "Something you wear on your foot";
objCategories.Update();
VB:
Dim objCategories As New Categories()
objCategories.CategoryID = 1
objCategories.CategoryName = "Shoes"
objCategories.Description = "Something you wear on your foot"
objCategories.Update()
[ back to top ]
Generated Code Features/Uses
Listed below are features and uses of the the code that are generated by AspxCodeGen 4.0.
| Generated Code |
Features |
| #1 Business Object Class |
- Note: The only code you call from your application
- Used as the gateway middle layer object the client calls
- Most CRUD calls can be made in one (1) line of code
- Inherits from the respective BusinessObjectBase class
- You can add additional code here (it will not be rewritten by the generator)
- One Class is generated per table
- Located in the \BusinessObject\ folder
|
| #2 Business Object Base Class |
- Used as the base class to the Business Object class
- Do not add or edit code here
- Encapsulates calls to the data layer
- Contains table fields as properties
- One Class is generated per table
- Located in the \BusinessObjectBase\ folder
|
| #3 Data Layer Class |
- Used as the gateway data layer object the middle tier objects call
- Inherits from the respective DataLayerBase class
- You can add additional code here (it will not be rewritten by the generator)
- One Class is generated per table
- Located in the \DataLayer\ folder
|
| #4 Data Layer Base Class |
- Used as the base class to the Data Layer class
- Do not add or edit code here
- Encapsulates calls to Stored Procedures or Dynamic SQL
- One Class is generated per table
- Located in the \DataLayerBase\ folder
|
| #5 Business Object Collection Class |
- Used as the Collection of the Business Object Class.
- One Class is generated per table.
|
| #6 Stored Procedure |
- Created in the database and used for CRUD operations
- Do not rewrite or edit generated stored procedure, instead, add a new one
- Generated Stored Procedures may include; select all, select by primary key, insert, update, delete, and more operations
- Generated only when the Stored Procedure option is selected
- At least 5 Stored Procedures are generated per table (for most tables)
- Located directly in the database
|
| #7 Dynamic SQL Class |
- Contains T-SQL CRUD operations in the code.
- Generated Dynamic SQL may include; select all, select by primary key, insert, update, delete, and more operations.
- Generated only when the Dynamic SQL option is selected.
- One Class is generated per table.
|
| #8 Example Class |
- Generated solely to show how to use the Generated Code
- Example code can be copied and pasted directly to your client code (ASP.Net web forms, Win Forms, Web Services, etc.)
- You can delete the whole directory if you don't need it
- One Class is generated per table
- Located in the \Example\ folder
|
| #9 Helper Classes and More |
- Contains minimal helper methods that helps the middle-tier or data-tier codes
- Dbase.cs contains static/shared methods/functions that connect to the database
- Dbase.cs contains the connection string to the database
- Functions.cs contains static/shared functions/methods used in GridViews
- Located in the \Helper\ folder
|
[ back to top ]
Product Comparison, Code Sample, and Pricing
Listed below are the comparative features of AspxCodeGen's Professional Plus and Express editions. Click the links
provided below for sample code of the respective features. Note: Sample code snapshots C# or VB.NET were taken from the
generated code based on Microsoft's Northwind database.
[ back to top ]
|
|