This project is read-only.
The SimpleDataFramework is an open source project, providing the necessary templates and C# helper classes to generate a simple but effective data framework using the Apex Sql Code 2008 code-generation engine ( As a bonus, a reasonably-robust set of 'UI' .aspx files are generated for testing (and using) the data access framework.

Note: Apex SQL Code is currently available for free at (

The target audience is primarily C# Asp.Net developers looking for lightweight plumbing for a well-defined Sql Server database. The UI and data access code will make good use of your existing Indexes and Foreign Keys.

Typical 'generation' output results in: (when running the ApexSqlCode 'project' file)

T-Sql Scrips: sql_StoredProcedures.sql contains CRUD stored procedure definitions for the tables selected in Apex SQL Code 2008. sql_TimeStampTriggers.sql contains triggers for the optional updating of time-stamp fields.

Template properties control what types of procs are created, including flags for creating additional Select procs on foreign keys and any remaining indexed columns.

'Entity' Custom Classes (C#): 2 for each table selected. 1 base class contains a C# class representation of a table's fields (and other helpful data constructs). An additional file is created with an inherting class, primarily as a safe place for your customizations and extensions.

'DAL Custom Classes (C#): 2 for each table selected. 1 static base class with methods calling a table's CRUD stored procedures. An additional file is created with an inheriting class, primarily for your customizations and extensions.

Some of the "Dal" classes accept parameters with simple data types (Int32, String, etc), others accept or return custom "entity" classes (described above). The typical "heavy lifting" of data would involve instantiating a new entity class (or receiving one or more as a result of a Select call), populating or changing entity class properties, and then passing the entity class on to a static DAL class for applying the changes to the database.

.aspx Web Page: 1 for each table selected.

The .Aspx files implement a pageable GridView responding to parametrized data selection, and a DetailsView for Inserting, Updating and Deleting data (via ObjectDataSources accessing the generated framework objects). Links are also provide to display related tables (following defined data relationships in the database). This page is designed primarily for testing the data framework calls and for 'scaffolding' or 'administrative' data access. Custom data validation and other features that are typically required in 'end-user' applications can be quickly added by enhancing the generated code.

Keeping it simple

It is important to note that the generated code does not produce "ORM"-style hierarchical objects. However, data from table selects are nicely wrapped in custom classes (C# classes representing database tables) and the classes are then wrapped in generic lists for a multi-row result set. Also, as part of a goal to 'keep it simple', the generated code relies on a small library of provided C# classes which do enough to get the job done while leaving it very easy to step through the code (and make your own enhancements if you like). It all works with "out-of-the-box" Visual Studio 2008 and the Microsoft .net framework (2.0 and above).

Also note that common interfaces such as ICloneable and IComparable are not implemented, it doesn't manage transactions, and serialization has not been tested.

What's in the download

ApexSqlCode_Templates folder contains 8 templates and a project file for use with Apex Sql Code 2008.

The CodeGenUtil project must be compiled and the DLL placed into ApexSQL Code's bin folder (C:\Program Files\ApexSQL\ApexSQLCode2008\bin). It exposes methods that are used extensively by the templates while generating the code.

The SDF (SimpleDataFramework) Visual Studio project is the c# class library 'framework'.

The AdventureWorksLtSample Visual Studio project in the SDF folder is a sample project running on a (local) AdventureWorksLT database (( For now this project serves as the only 'documentation' for creating a project with generated code. Based on the prefix of the generated file names, generated files are to be placed in project folders: Sdf.Entities, Sdf.DAL and AdminUI (the folder names can be anything; the naming here was chosen to represent the namespaces of contained files -- selected at generation time). ui_TableOfTables.aspx makes a good default document. You'll want to be sure to reference the SDF framework project or the DLL.

...more to come...

Last edited May 7, 2009 at 2:03 PM by Yelnoc, version 27