Accessing Code from a Client
AspxFormsGen 4.5 has two code generating engines; AspxFormsGen which generates the Front End (UI, Web Forms), and AspxCodeGen which generates the Middle and Data Tier and Stored Procedures. Code generated by the AspxCodeGen 4.5 engine can be used by other clients/applications, all you really have to do is remove them (Middle and Data Tier) from the generated web site and move to another project such as a Class Library project, Web API, WCF, Web Service, etc. The Middle Tier and Data Layer code are located under the web site's App_Code folder, the Stored Procedures are already in MS SQL (so you don't need to move them).

The code examples below are based on a "Categories" table found in the Northwind database. These examples are copied from a class called CategoriesExample (.cs or .vb) generated by AspxFormsGen 4.5. This is how simple it is to call the middle tier objects from your client (web form, win form, web service, web api 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 from any client 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 shown 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)


Select, Skip, Take: E.g. Select 10 records starting in index 16 ordered by CategoryID ascending.
C#:
int totalRecordCount;
var cat = Categories.SelectSkipAndTake(10, 16, out totalRecordCount, "CategoryID");

VB:
Dim totalRowCount As Integer
Categories.SelectSkipAndTake(10, 16, totalRowCount, "CategoryID")


Select, Skip, Take Using Filters (Search): E.g. Select Where CategoryName is Like '%Bev%', Take 10 records starting in index 16 ordered by CategoryID descending.
C#:
int totalRecordCount;
int? categoryID = null;
string categoryName = "Bev";
var cat = Categories.SelectSkipAndTakeDynamicWhere(categoryID, categoryName, 10, 0, out totalRecordCount, "CategoryID DESC");

VB:
Dim totalRecordCount As Integer
Dim categoryID As Integer? = Nothing
Dim categoryName As String = "Bev"
Dim cat = Categories.SelectSkipAndTakeDynamicWhere(categoryID, categoryName, 10, 0, totalRecordCount, "CategoryID DESC")


Get the Total Number of Records in the Categories Table:
C#:
int totalRecordCount = Categories.GetRecordCount();

VB:
Dim totalRecordCount As Integer = = Categories.GetRecordCount()


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()
* Please see notes.