当前位置: 首页>>代码示例>>C#>>正文


C# Generator.GenerateTable方法代码示例

本文整理汇总了C#中Generator.GenerateTable方法的典型用法代码示例。如果您正苦于以下问题:C# Generator.GenerateTable方法的具体用法?C# Generator.GenerateTable怎么用?C# Generator.GenerateTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Generator的用法示例。


在下文中一共展示了Generator.GenerateTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static int Main(string[] args)
        {
            if (args.Length < 2 || args.Length > 6)
            {
                PrintUsageGuide();
                return 2;
            }
            else
            {
                try
                {
                    string connectionString = args[0];
                    string outputFileLocation = args[1];

                    bool includeData = true;
                    bool includeSchema = true;
                    bool saveImageFiles = false;
                    bool keepSchemaName = false;
                    bool preserveDateAndDateTime2 = false;
                    bool sqlite = false;
                    System.Collections.Generic.List<string> exclusions = new System.Collections.Generic.List<string>();

                    for (int i = 2; i < args.Length; i++)
                    {
                        if (args[i].StartsWith("dataonly"))
                        {
                            includeData = true;
                            includeSchema = false;
                        }
                        if (args[i].StartsWith("schemaonly"))
                        {
                            includeData = false;
                            includeSchema = true;
                        }
                        if (args[i].StartsWith("saveimages"))
                            saveImageFiles = true;
                        if (args[i].StartsWith("keepschema"))
                            keepSchemaName = true;
                        if (args[i].StartsWith("preservedateanddatetime2"))
                            preserveDateAndDateTime2 = true;
                        if (args[i].StartsWith("exclude:"))
                            ParseExclusions(exclusions, args[i]);
                        if (args[i].StartsWith("sqlite"))
                        {
                            sqlite = true;
                            includeSchema = true;
                        }
                    }


                    using (IRepository repository = new ServerDBRepository(connectionString, keepSchemaName))
                    {
                        Helper.FinalFiles = outputFileLocation;
                        System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
                        sw.Start();
                        var generator = new Generator(repository, outputFileLocation, false, preserveDateAndDateTime2, sqlite, keepSchemaName);

                        generator.ExcludeTables(exclusions);
                        if (sqlite)
                        {
                            generator.GenerateSqlitePrefix();
                            if (includeSchema)
                            {
                                Console.WriteLine("Generating the tables....");
                                generator.GenerateTable(false);
                            }
                            Console.WriteLine("Generating the data....");
                            generator.GenerateTableContent(false);
                            Console.WriteLine("Generating the indexes....");
                            generator.GenerateIndex();
                            generator.GenerateSqliteSuffix();
                        }
                        else
                        {
                            // The execution below has to be in this sequence
                            if (includeSchema)
                            {
                                Console.WriteLine("Generating the tables....");
                                generator.GenerateTable(includeData);
                            }
                            if (includeData)
                            {
                                Console.WriteLine("Generating the data....");
                                generator.GenerateTableContent(saveImageFiles);
                            }
                            if (includeSchema)
                            {
                                Console.WriteLine("Generating the primary keys....");
                                generator.GeneratePrimaryKeys();
                                Console.WriteLine("Generating the indexes....");
                                generator.GenerateIndex();
                                Console.WriteLine("Generating the foreign keys....");
                                generator.GenerateForeignKeys();
                            }
                        }
                        Helper.WriteIntoFile(generator.GeneratedScript, outputFileLocation, generator.FileCounter, sqlite);
                        Console.WriteLine("Sent script to output file(s) : {0} in {1} ms", Helper.FinalFiles, (sw.ElapsedMilliseconds).ToString());
                        return 0;
                    }
                }
//.........这里部分代码省略.........
开发者ID:inickvel,项目名称:SqlCeToolbox,代码行数:101,代码来源:Program2.cs

示例2: Main


//.........这里部分代码省略.........
                        {
                            using (var repo = Helper.CreateRepository(args[1]))
                            {
                                var dch = new DataContextHelper();
                                dch.GenerateWPDataContext(repo, args[1], args[2]);
                            }
                            return 0;
                        }
                        else
                        {
                            PrintUsageGuide();
                            return 2;
                        }
#endif
                    }

                    else
                    {
                        for (int i = 2; i < args.Length; i++)
                        {
                            if (args[i].Contains("dataonly"))
                            {
                                includeData = true;
                                includeSchema = false;
                            }
                            if (args[i].Contains("schemaonly"))
                            {
                                includeData = false;
                                includeSchema = true;
                            }
                            if (args[i].Contains("saveimages"))
                                saveImageFiles = true;
                            if (args[i].Contains("sqlazure"))
                                sqlAzure = true;
                            if (args[i].StartsWith("exclude:"))
                                ParseExclusions(exclusions, args[i]);
                        }

                        using (IRepository repository = Helper.CreateRepository(connectionString))
                        {

                            Helper.FinalFiles = outputFileLocation;
#if V40
                            var generator = new Generator4(repository, outputFileLocation, sqlAzure);
#else
                            var generator = new Generator(repository, outputFileLocation, sqlAzure);
#endif
                            generator.ExcludeTables(exclusions);
                            Console.WriteLine("Generating the tables....");
#if V31
                            generator.GenerateTable(false);
#else
                            generator.GenerateTable(includeData);
#endif
                            if (sqlAzure && includeSchema)
                            {
                                Console.WriteLine("Generating the primary keys (SQL Azure)....");
                                generator.GeneratePrimaryKeys();
                            }
                            if (includeData)
                            {
                                Console.WriteLine("Generating the data....");
                                generator.GenerateTableContent(saveImageFiles);
                            }
                            if (!sqlAzure && includeSchema)
                            {
                                Console.WriteLine("Generating the primary keys....");
                                generator.GeneratePrimaryKeys();
                            }
                            if (includeSchema)
                            {
                                Console.WriteLine("Generating the indexes....");
                                generator.GenerateIndex();
                                Console.WriteLine("Generating the foreign keys....");
                                generator.GenerateForeignKeys();
                            }
                            Helper.WriteIntoFile(generator.GeneratedScript, outputFileLocation, generator.FileCounter);
                        }
                        Console.WriteLine("Sent script to output file(s) : {0} in {1} ms", Helper.FinalFiles, (sw.ElapsedMilliseconds).ToString());
                        return 0;
                    }
                }
                catch (System.Data.SqlServerCe.SqlCeException e)
                {
                    Console.WriteLine(Helper.ShowErrors(e));
                    return 1;
                }
                catch (System.Data.SqlClient.SqlException es)
                {
                    Console.WriteLine(Helper.ShowErrors(es)); 
                    return 1;
                }

                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex);
                    return 1;
                }
            }
        }
开发者ID:herohut,项目名称:elab,代码行数:101,代码来源:Program.cs


注:本文中的Generator.GenerateTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。