<%[import namespace="System"]%> <%[import namespace="Mono.Data.Sql" assembly="Mono.Data.Sql.dll"]%> <%[import namespace="Centaurus.Library" assembly="Centaurus.dll"]%> <%[import template="../templates/extra/*.ccs"]%> <%[centaurus class="TableGenerator" signature="TableSchema table"]%> <% //TableSchema table = args[0] as TableSchema; if (table == null) throw new Exception (String.Format ("TableGenerator template wasn't supplied with a valid TableSchema. Object passed: {0}", table)); //table.GetConstraints (); // Helper to do method StringList paramList = new StringList (true); %> // Generated by Centaurus 0.1 - Copyright (C) Alexandre Gomes // Table: <%= table.FullName %> // <%[customcode key="bac"] table.Name%> namespace WideSolutions.Restaunet.Data { #region Row public class <%= table.Name %> { #region Constructors <% foreach (ColumnSchema column in table.Columns) { if (column.PrimaryKey) { paramList.Add (column.Provider.GetTypeFromDbType (column.DataTypeName) + " _" + column.Name); } } %>// Key-based constructor, for retrieving records public <%= table.Name %> (<%= paramList %>) { <% foreach (ColumnSchema column in table.Columns) { if (column.PrimaryKey) { %> this._<%= column.Name %> = _<%= column.Name %>; <% } } %> } <% foreach (ColumnSchema column in table.Columns) { paramList.Add (column.Provider.GetTypeFromDbType (column.DataTypeName) + " _" + column.Name); } %> // Insert/Create record constructor public <%= table.Name %> (<%= paramList %>) { <% foreach (ColumnSchema column in table.Columns) { %> this._<%= column.Name %> = _<%= column.Name %>; <% } %> } #endregion #region Columns <% foreach (ColumnSchema column in table.Columns) { %> /* Type: <%= column.DataTypeName %> */ <%= column.Provider.GetTypeFromDbType (column.DataTypeName) %> _<%= column.Name %>; public <%= column.Provider.GetTypeFromDbType (column.DataTypeName) + " " %> <%= column.Name %> { get { return _<%= column.Name %>; } set { _<%= column.Name %> = value; } } <% } %> #endregion } #endregion #region Table (row collection) #endregion }