ZenArchitect.NL (Henk van Dijken)

the art of model-driven code generation

Archive for the ‘business entity’ tag

Generation of a Business Entity

with one comment

image

Now it is time to generate some business entities from a model.

Suppose we have a simplified model with just one entity called Course. It has an unique identifier CourseID and a searchable and displayable attribute called CourseName.

To generate source code the model is injected into the following template.

image

The resulting generated code will look like this:

public class Course
{
    public int m_CourseID;
    public string m_CourseName;

    public int CourseID
    {
        get
        {
            return m_CourseID;
        }
        set
        {
            if (value != m_CourseID)
            {
                m_CourseID = value;
            }
        }
    }

    public string CourseName
    {
        get
        {
            return m_CourseName;
        }
        set
        {
            if (value != m_CourseName)
            {
                m_CourseName = value;
            }
        }
    }
}

That’s all.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Written by Henk van Dijken

October 30th, 2009 at 7:50 pm

Posted in Code Generation

Tagged with ,