// SUMMARY: Create data for definition class private string ConstructDefinitionTableClass(DMGTableInfo table) { string data = this.FillSharedData(this.GetTemplateContent("Definition")); data = data.Replace("[table_class_name]", table.ClassName); return(data); }
/// PRIVATES /// public virtual List <DMGTableInfo> GetTables() { List <DMGTableInfo> result = new List <DMGTableInfo>(); var data = this.Database.Load <DMGInitialSqlResponse>(this.Query); foreach (var row in data) { if (this.IgnoreTables.Contains <string>(row.table_name)) { continue; } var table = (from r in result where r.TableName.Equals(row.table_name) select r).FirstOrDefault(); if (table == null) { table = new DMGTableInfo() { Schema = row.schema, TableName = row.table_name }; result.Add(table); } var column = new DMGColumnInfo() { Name = row.column_name, Default = row.column_default, Length = row.length, IsPrimary = table.Columns.Count == 0, Type = row.type, IsNullable = row.is_nullable != null && row.is_nullable.Equals("YES") }; column.TranslatedType = this.GetColumnType(column.Type, column.IsNullable); table.Columns.Add(column); } return(result); }
// SUMMARY: Create Model class private string ConstructTableClass(DMGTableInfo table) { string data = this.FillSharedData(this.GetTemplateContent("Model")); data = data.Replace("[table_name]", table.TableName) .Replace("[table_class_name]", table.ClassName) .Replace("[table_id]", table.Columns[0].Name) .Replace("[table_schema]", table.Schema); string columnData = ""; foreach (var column in table.Columns) { string columnTemplate = this.GetTemplateContent("Column") .Replace("[column_name]", column.Name) .Replace("[column_type]", this.GetColumnType(column.Type, column.IsNullable)) .Replace("[column_value]", this.GetDefaultValue(column)) .Replace("[dcolumn]", this.GetDColumnData(column)); columnData += columnTemplate; } return(data.Replace("[table_content]", columnData));; }