15May/070
Data Tier Generator – Planning
Now, here's my Entity definition. This definition would vary from project to project and would be the only thing I'd have to change.
<br />
<nTier projectPrefix="prj"><br />
<entity name="Tag" primaryKeys="id"><br />
<properties><br />
<property name="id" sqlType="bigint" notnull="true" /><br />
<property name="text" sqlType="nvarchar(50)" notnull="true" /><br />
</properties><br />
<indices><br />
<index columns="text" /><br />
</indices><br />
</entity><br />
<entity name="Article" primaryKeys="id"><br />
<properties><br />
<property name="id" sqlType="bigint" notnull="true" /><br />
<property name="title" sqlType="nvarchar(255)" notnull="true" /><br />
<property name="content" sqlType="xml" /><br />
</properties><br />
<indices><br />
<index columns="title" /><br />
</indices><br />
</entity><br />
<entity name="ArticleTag" primaryKeys="articleId, tagId"><br />
<properties><br />
<property name="articleId" sqlType="bigint" notnull="true" /><br />
<property name="tagId" sqlType="bigint" notnull="true" /><br />
</properties><br />
</entity><br />
</nTier><br />
Now, here's how it's all structured:
- Each entity tag will correspond to a database table and most of the time an C# class. There're exceptions such as the link-tables. I'll explain that when I get to one.
- The projectPrefix attribute specifies the prefix that would be added to each table and stored procedure generated. For example, the entity Article would generate a table prj_Article
- Each property tag inside properties tag will correspond to a table column and a public property in the generated class.
- The primaryKeys attribute can be used to provide a comma seperated list of primary key columns
- The indices tag is used to specify nonclustered indexes for the table. The columns attribute accepts a comma seperated list of columns