Home
News
Downloads
Documentation
Samples
Forums







Documentation

At the moment, I don't have a great deal of time to write documentation for DNDL so I'm throwing this quick start section which will simply show some examples of how it's used. First of all, in the 1.1 binary release .ZIP you'll find a .cst file. This is a CodeSmith Template. Using this template with CodeSmith, you can easily create your database objects. I highly recommend taking this route as it takes only seconds to create your data objects from the database as opposed to potentially hours of tedious typing.

Once your objects have been generated, working with them is a piece of cake. There are currently Sql and OleDb specific objects. The examples use the Sql provider. To use the OleDb provider, simply replace the letters "Sql" with "OleDb" in the object names. Here are some examples:

To load an object, let's say the ever perfect "Employee" example, where we have a class called Employee, we would use:

DALReader reader = new DALSqlReader(connStr);
Employee employee = reader.LoadSingleObjectWhere(typeof(Employee), "Name='Pete Davis'");

There are several other methods for loading by the primary key or for loading objects into collections that implement the IList interface. For example:

DALReader reader = new DALSqlReader(connStr);
EmployeeVector employees = new EmployeeVector();
int numRecs = reader.LoadMultipleObjectsWhere(typeof(Employee), employees, "Name LIKE '%Davis%'");

Saving objects is even simpler. There are only 3 public methods for the DALWriter class: SaveObject(), SaveObjects(), and DeleteObject(). A simple example:

DALWriter writer = new DALSqlWriter(connStr);
reader.SaveObjects(employees);

If the object already exists in the database, it will be updated. If it does not yet exist, it will be inserted.

When I have time, I'd like to provide some more extensive code samples, discuss the caching mechanism and in general, distribute more information. Hopefully this will be good for a start, and feel free to post questions on the site.











Steves free web site templates

SourceForge.net Logo