Example #1
0
 public string GetDbClassText()
 {
     var result = new StringBuilder();
     result.AddHeaderWarning();
     result.AppendLine("using System;");
     if (AppConfiguration.UseInterfacesForDbClasses)
         result.AppendLine("using " + AppConfiguration.DbInterfacesNamespace + ";");
     result.AppendLine();
     result.AppendLine("namespace " + AppConfiguration.DbClassesNamespace);
     result.AppendLine("{");
     result.Append("\tpublic class " + ModelTableName + "Db");
     if (AppConfiguration.UseInterfacesForDbClasses)
         result.Append(": I" + ModelTableName + "Db");
     result.AppendLine();
     result.AppendLine("\t{");
     foreach (ColumnInfo columnInfo in Columns)
     {
         result.AppendLine("\t\tpublic " + columnInfo.CSharpType + " " +
                           columnInfo.ColumnName + " { get; set; }");
     }
     result.AppendLine("\t}");
     result.AppendLine("}");
     return result.ToString();
 }
Example #2
0
        public string GetRepositoryText()
        {
            var result = new StringBuilder();
            result.AddHeaderWarning();
            PutRepositoryUsing(result);
            result.AppendLine();
            result.AppendLine("namespace " + AppConfiguration.DbRepositoryNamespace);
            result.AppendLine("{");

            if (AppConfiguration.DbRepositoryIsPartialClass)
            {
                result.AppendLine("\tpublic partial class DbRepository");
            }
            else
            {
                result.AppendLine("\tpublic class " + ModelTableName + "Repository: DbRepository");
            }

            result.AppendLine("\t{");
            if (!AppConfiguration.DbRepositoryIsPartialClass) PutRepositoryConstructors(result);
            PutSaveMethod(result);
            PutGetByIdMethod(result);
            PutGetAllMethod(result);
            PutDeleteMethod(result);
            result.AppendLine("\t}");
            result.AppendLine("}");
            return result.ToString();
        }