Henk van Dijken
This user hasn't shared any biographical information
Homepage: http://www.henkvandijken.nl
Posts by Henk van Dijken
Generating Business Entities from a Database Model
Jul 29th
After Generating Database Objects from an UML Model you are desperately in need of a data access layer (DAL) and a business logic layer (BLL). Today we are going to generate the famous Business Entities.
After executing that funny sql-script we generated from UML previously, you are the proud owner of a database. Since I am a great fan of MyGeneration we will use a similar approach and scrape the meta model from the database.
To be able to do so, the code generator needs some input. First, it has to know which tables must be read (filter) and where to find the tables (database) to extract meta data from.
At this point the generator has enough information to read the data model and generate code. The list of tables are traversed and classes are created. Within each table the meta data of its columns are extracted.
Since we – at this moment – are not able to automagically convert data types, we also need a support routine for conversion of database type to its C#.NET equivalent. This is done by append some script to the template.
Finally, using this template, the following code is generated from the selected data model.
/*------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// ZaosGenerator Version: 1.0.0.0
// Template Author : Henk van Dijken
// Generation Date : 29-7-2010 21:12:15
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//----------------------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Text;
namespace ZenArchitect2.BusinessEntities
{
public partial class TestParent
{
public TestParent() {}
private int TestParentIDField;
public int TestParentID
{
get { return this.TestParentIDField; }
set { this.TestParentIDField = value; }
}
private string TestParentName1Field;
public varchar TestParentName1
{
get { return this.TestParentName1Field; }
set { this.TestParentName1Field = value; }
}
private int TestParentNumberField;
public int TestParentNumber
{
get { return this.TestParentNumberField; }
set { this.TestParentNumberField = value; }
}
}
public partial class TestChild
{
public TestChild() {}
private int TestChildIDField;
public int TestChildID
{
get { return this.TestChildIDField; }
set { this.TestChildIDField = value; }
}
private int TestParentIDField;
public int TestParentID
{
get { return this.TestParentIDField; }
set { this.TestParentIDField = value; }
}
private string TestChildNameField;
public varchar TestChildName
{
get { return this.TestChildNameField; }
set { this.TestChildNameField = value; }
}
}
}
Yes! You can find me again…
Jul 26th
I am very proud to announce that I fixed my site/blog its redirecting mechanism, so that you can find me again via Google.
Oops. I did it again…
Jun 30th
Sorry, my blog is temporarily unavailable. It is under (re)construction towards blog 4.0.
Or, to be more honest. I screwed up, again.
1-2-3. See, there it is again. Now I only have to find/reconstruct my pictures.
Yes! I found them again. There they are. So, another happy blogger is on line.
But wait, this is an excellent opportunity to refactor some stuff. Good idea. I’ll do that.
So, meanwhile apologies for the inconvenience.
I’ll promise that next time I’ll try to backup first before doing a restore, instead of the other way around.












