Beispiel #1
0
        private StringBuilder GenerateFakeRepositories(Table table)
        {
            var code = new StringBuilder();

            code.AppendLine("\nnamespace " + Database.DefaultNamespace);
            code.AppendLine("{");
            code.AppendLine("\tusing System.Linq;");
            code.AppendLine();
            code.AppendLine("\tpublic partial class Fake" + table.ClassName + "Repository : I" + table.ClassName + "Repository");
            code.AppendLine("\t{");
            code.AppendLine("\t\tpublic EntityDataContext DataContext { get; private set; }");
            code.AppendLine();

            DataAccessLayerGenerator generator = new CSharpFakeDataAccessLayerCodeGenerator(code, table, false);

            generator.GenerateSelectAll();
            generator.GenerateSelectWithTop();
            generator.GenerateSelectBy();
            generator.GenerateSelectByWithTop();
            generator.GenerateCreate();
            generator.GenerateCreateIgnoringPrimaryKey();
            generator.GenerateCreateUsingAllColumns();
            generator.GeneratePopulate();
            generator.GenerateDelete();
            generator.GenerateDeleteBy();
            generator.GenerateDeleteAll();
            generator.GenerateUpdate();
            generator.GenerateCount();

            code.AppendLine("\t}");
            code.AppendLine("}");

            return(code);
        }
        private StringBuilder GenerateFakeRepositories(Table table)
        {
            var code = new StringBuilder();

            code.AppendLine("\nnamespace " + Database.DefaultNamespace);
            code.AppendLine("{");
            code.AppendLine("\tusing System.Linq;");
            code.AppendLine();
            code.AppendLine("\tpublic partial class Fake" + table.ClassName + "Repository : I" + table.ClassName + "Repository");
            code.AppendLine("\t{");
            code.AppendLine();

            var generator = new CSharpFakeDataAccessLayerCodeGenerator(code, table);

            generator.GenerateCreateEntity();

            var options = DataAccessLayerGeneratorOptions;

            if (options.GenerateSelectAll)
            {
                generator.GenerateSelectAll();
            }

            if (options.GenerateSelectAllWithTop)
            {
                generator.GenerateSelectWithTop();
            }

            if (options.GenerateSelectBy)
            {
                generator.GenerateSelectBy();
            }

            if (options.GenerateSelectByWithTop)
            {
                generator.GenerateSelectByWithTop();
            }

            if (options.GenerateSelectByTwoColumns)
            {
                generator.SelectByTwoColumns();
            }

            if (options.GenerateSelectByThreeColumns)
            {
                generator.SelectByThreeColumns();
            }

            if (options.GenerateCreate)
            {
                generator.GenerateCreate();
            }

            if (options.GenerateCreateIgnoringPrimaryKey)
            {
                generator.GenerateCreateIgnoringPrimaryKey();
            }

            if (options.GenerateCreateUsingAllColumns)
            {
                generator.GenerateCreateUsingAllColumns();
            }

            if (options.GeneratePopulate)
            {
                generator.GeneratePopulate();
            }

            if (options.GenerateDelete)
            {
                generator.GenerateDelete();
            }

            if (options.GenerateDeleteBy)
            {
                generator.GenerateDeleteBy();
            }

            if (options.GenerateDeleteAll)
            {
                generator.GenerateDeleteAll();
            }

            if (options.GenerateUpdate)
            {
                generator.GenerateUpdate();
            }

            if (options.GenerateCount)
            {
                generator.GenerateCount();
            }

            code.AppendLine("\t}");
            code.AppendLine("}");

            return(code);
        }