Data Layer Generator
Data Layer Generator is designed to save you time in developing your Visual Studio .Net applications, and to reduce the number of coding errors. This program is a code generator that will generate C# (Microsoft .Net 4.8 Framework) code that allows the business layer of an application to communicate with the data layer.
This utility allows you to easily create an object-oriented C# data layer for your SQL Server 2005/2008/2010/2019 database. Within approximately two minutes you can step through the three screens necessary to generate a complete set of classes for doing your basic insert, update, and delete functions on each table in the database without writing a single line of SQL code. In addition, the utility creates all the necessary stored procedures for inserting, updating, and deleting.
When you generate your data access layer, the program will create multiple classes, one for each table in your database. Each class contains methods for inserting, updating and deleting as well as properties that map to each column in the table the class represents. Each C# class represents a row in the related table and the program also produces custom collections that map to multiple records in the table.
For an easy example, let’s consider you have an existing database with one table called TCustomer. After running the utility and selecting your existing database, the program will output a class called TCustomer.cs and TCustomers.cs. The first class (TCustomer.cs) will contain properties that directly map to each column in the table so there might be a property called LastName, FirstName, and SocialSecurityNumber. This class will also have the following methods created that allow you manipulate data in that table:
Insert – inserts all of the properties into a new record in the database
Update – updates the current properties to an existing record in the database
Delete – removes a given record from the database
SelectOne – given a primary key, will retrieve one record from the database and returns an instance of the TCustomer class.
SelectAll – returns all the records in TCustomer in the form of an instance of the custom collection (TCustomers)
SelectByField – gets all records in TCustomer where the given field equals the given value and returns a collection of TCustomers
There are also some additional methods that are created when logical keys have been defined on a set of fields in a table (e.g. SelectOneByTCustomer_LogicalKeyName) and there are other methods created that handle returning child records from other tables by virtue of foreign keys (e.g. SelectOneWithTInvoices).
This utility will save you many hours of coding basic crud functionality and currently produces C# classes and stored procedures that support SQL Server 2005, SQL Server 2008, SQL Server 2010. and SQL Server 2019.