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


C# InsertCommand.BuildSql方法代码示例

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


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

示例1: Generate


//.........这里部分代码省略.........
                                {
                                    Console.WriteLine("Circular references in foreign keys found in {0}", td.RealType.FullName);
                                    Console.WriteLine(" to {0}", refTd.RealType.FullName);
                                }
                                break;
                            }
                        }
                    }
                    if (!notScriptedReference)
                    {
                        i = 0;
                        notScripted.Remove(td);
                        scripted.Add(td);
                    }
                }

                if (OptionValue("noTables") == null)
                {
                    for (int j = scripted.Count - 1; j >= 0; j--)
                    {
                        TypeDescriptor td;
                        IList tables2Delete = new ArrayList();
                        for (int ii = j - 1; ii >= 0; ii--)
                        {
                            td = (TypeDescriptor)scripted[ii];
                            foreach (string tableName in td.TableNames.Keys)
                            {
                                if (!tables2Delete.Contains(tableName))
                                    tables2Delete.Add(tableName);
                            }
                        }

                        td = (TypeDescriptor)scripted[j];
                        var tables = new List<string>();
                        foreach (string tableName in td.TableNames.Keys)
                        {
                            if (!tables2Delete.Contains(tableName))
                            {
                                tables.Add(tableName);
                            }
                        }

                        Target.WriteLine(new DeleteEntityCommand(dt).BuildSql(td, tables)[0]);
                    }

                    foreach (TypeDescriptor td in scripted)
                    {
                        var tables = new List<string>();
                        foreach (string tableName in td.TableNames.Keys)
                        {
                            if (!scriptedTables.Contains(tableName))
                            {
                                tables.Add(tableName);
                                scriptedTables.Add(tableName);
                            }
                        }

                        Console.WriteLine("Parsing class {0}...", td.RealType.FullName);
                        Target.WriteLine(new CreateEntityCommand(dt).BuildSql(td, tables)[0]);
                    }
                }

                if (OptionValue("sp") != null)
                {
                    Console.WriteLine("Generation standard stored procedures...");
                    foreach (TypeDescriptor td in scripted)
                    {
                        Target.WriteLine(new CreateStandardProceduresCommand(dt).BuildSql(td)[0]);
                    }
                }

                if (OptionValue("r") != null)
                {
                    Console.WriteLine("Generation reference data...");
                    foreach (TypeDescriptor td in scripted)
                    {
                        try
                        {
                            Target.WriteLine();
                            Target.WriteLine("-- Table " + td.Name);
                            IPersistent obj = (IPersistent)Activator.CreateInstance(td.RealType);
                            foreach (IPersistent o in obj.DefaultValues())
                            {
                                var command = new InsertCommand(dt);
                                string sql = command.BuildSql(td, SqlGenerator.GetObjectParameters(o), false)[0];
                                if (dt == DAType.Oracle)
                                    sql += "\r\n;\r\n";
                                Target.WriteLine(sql);
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(string.Format("Error for class {0}: {1}", td.Name, ex.Message));
                        }
                    }
                }
                Target.Flush();
                Console.WriteLine("Creation scripts successfully created.");
            }
        }
开发者ID:jcde,项目名称:CommandUtils,代码行数:101,代码来源:Start.cs


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