Example #1
0
        static void Main(string[] args)
        {
            //Console.WriteLine(FileHelper.MapPath("/"));

            using (var db = new MyCodeSqlSugarClient())
            {
                var tables = db.DbMaintenance.GetTableInfoList();

                var solutionPath = FileUtils.GetSolutionPath();

                Console.WriteLine($"当前解决方案所在目录:{solutionPath}");

                //生成所有实体
                db.DbFirst.IsCreateAttribute(true).CreateClassFile(Path.Combine(FileUtils.GetSolutionPath(), "MyCode.Project.Domain", "Model"), "MyCode.Project.Domain.Model");

                foreach (var table in tables)
                {
                    Console.WriteLine(table.Name);

                    //创建仓储接口
                    var templateForRepositoryInterface = new TemplateForRepositoryInterface(table.Name);
                    templateForRepositoryInterface.CreateFile();

                    //创建仓储实现类
                    var templateForRepository = new TemplateForRepository(table.Name);
                    templateForRepository.CreateFile();
                }

                Console.WriteLine("代码生成成功");
            }


            Console.ReadKey();
        }
Example #2
0
        static void Main(string[] args)
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.InitMyDotNetCore();

            var serviceProvider = serviceCollection.BuildServiceProvider();

            using (var db = serviceProvider.GetService <ISqlSugarClient>())
            {
                var tables = db.DbMaintenance.GetTableInfoList();

                var solutionPath = FileHelper.GetSolutionPath();

                Console.WriteLine($"当前解决方案所在目录:{solutionPath}");

                //生成所有实体
                db.DbFirst.IsCreateAttribute(true).CreateClassFile(Path.Combine(solutionPath, "MyDotNetCore.Project.Domain", "Model"), "MyDotNetCore.Project.Domain.Model");

                foreach (var table in tables)
                {
                    Console.WriteLine(table.Name);

                    //创建仓储接口
                    var templateForRepositoryInterface = new TemplateForRepositoryInterface(table.Name);

                    templateForRepositoryInterface.CreateFile();

                    //创建仓储实现类
                    var templateForRepository = new TemplateForRepository(table.Name);

                    templateForRepository.CreateFile();
                }
            }


            Console.WriteLine("代码生成成功");
        }