Data Tier Generator - Planning
 

by Sameera on May 15, 2007 21:15

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.

[code:xml]
<nTier projectPrefix="prj">
  <entity name="Tag" primaryKeys="id">
      <properties>
          <property name="id" sqlType="bigint" notnull="true" />
          <property name="text" sqlType="nvarchar(50)" notnull="true" />
      </properties>
      <indices>
          <index columns="text" />
      </indices>
  </entity>
  <entity name="Article" primaryKeys="id">
      <properties>
          <property name="id" sqlType="bigint" notnull="true" />
          <property name="title" sqlType="nvarchar(255)" notnull="true" />
          <property name="content" sqlType="xml" />
      </properties>
      <indices>
          <index columns="title" />
      </indices>
  </entity>
  <entity name="ArticleTag" primaryKeys="articleId, tagId">
      <properties>
          <property name="articleId" sqlType="bigint" notnull="true" />
          <property name="tagId" sqlType="bigint" notnull="true" />
      </properties>
  </entity>
</nTier>
[/code]

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

Tags: ,

Filed Under: Code Snippets

Add comment


(Will show your Gravatar icon)  

biuquote
  • Comment
  • Preview
Loading



About Me

Sameera Perera

Sameera Perera

Log in

RecentComments

Comment RSS

Calendar

<<  November 2008  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

Archive

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

All forms of source code published on Codoxide.com are distributed under the Apache License, Version 2.0 unless otherwise stated.
The rest of the content are published under a Creative Commons Attribution 3.0 License.
Creative Commons License

CodoxideTM

Copyright © 2008  codoxide.com. All rights reserved. Designed by Sameera Perera