Tutorial 1: How to create a DDL file out of your business entities
Posted by Gerhard Stephan on May 15th, 2006
The first ObjectMapper .NET tutorial shows how to create a valid DDL file out of your business entities.
First we will need some business entities. In terminology of the ObjectMapper .NET, Business Entities are called "ValueObjects". That is because they will only contain the raw values.
In the first draw we will have an user class, his marketplace items and the bids. Our szenario: A user wants to sell marketplace items to an other user which can place bids on the items.
To export the entities we have to add the entity types to an ArrayList().
///<summary>/// Gets the business entity types.///</summary>///<value>The business entity types.</value>private ArrayList BusinessEntityTypes{get{ArrayList result = new ArrayList();result.Add(typeof(User));result.Add(typeof(MarketplaceItem));result.Add(typeof(Bid));return result;}}
Than the DDL file can be exported by the ObjectMapper .NET and the WriteSchema method.
///<summary>/// Exports the access DDL.///</summary>private void ExportAccessDDL(){IPersister accessPersister = new AccessPersister();ObjectMapper mapper = CreateMapper(accessPersister);mapper.WriteSchema("Marketplace.access.sql", BusinessEntityTypes);mapper.Dispose();ShowFile("Marketplace.access.sql");}
But that’s not only possible for a Microsoft Access database. It’s also possible for Oracle, Microsoft SQL Server and XML Schema files.
The demo can be downloaded using the following link:

May 16th, 2006 at 10:37 pm
Hi Gerhard,
i idented the C# code - now the format looks much better!
Greetings
Karl