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


C# Schema.ToString方法代码示例

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


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

示例1: checkProp

 private static void checkProp(Schema s0)
 {
     if (s0.Type == Schema.UNION) return; // unions have no props
     Assert.AreEqual(null, s0["foo"]);
     Schema s1 = Schema.Parse(s0.ToString());
     s1["foo"] = "bar";
     Assert.AreEqual("bar", s1["foo"]);
     Assert.IsFalse(s0 == s1);
     Schema s2 = Schema.Parse(s1.ToString());
     Assert.AreEqual("bar", s2["foo"]);
     Assert.IsTrue(s1.Equals(s2));
     Assert.IsFalse(s0 == s2);
 }
开发者ID:thirumg,项目名称:Avro.NET,代码行数:13,代码来源:TestSchema2.cs

示例2: CreateSelectProcedure

        private void CreateSelectProcedure(Schema spSchema, Table tbl)
        {
            String procName;
            StringBuilder sbSQL = new StringBuilder();
            StringBuilder sbSelect = new StringBuilder();
            StringBuilder sbWhere = new StringBuilder();
            StoredProcedure sp;
            StoredProcedureParameter parm;

            try
            {
                // Create stored procedure name from user entry and table name
                procName = PrefixTextBox.Text + tbl.Name + @"Select";

                if (DropOnlyCheckBox.CheckState == CheckState.Checked)
                {
                    DropStoredProcedure(procName, spSchema);
                }
                else
                {
                    DropStoredProcedure(procName, spSchema);
                    ScriptTextBox.AppendText(string.Format(
                        System.Globalization.CultureInfo.InvariantCulture,
                        Properties.Resources.CreatingStoredProcedure,
                        spSchema.ToString(), BracketObjectName(procName))
                        + Environment.NewLine);
                    ScrollToBottom();

                    // Create the new stored procedure object
                    sp = new StoredProcedure(tbl.Parent, procName, spSchema.Name);
                    sp.TextMode = false;
                    foreach (Column col in tbl.Columns)
                    {
                        // Select columns
                        if (sbSelect.Length > 0)
                        {
                            sbSelect.Append(", " + Environment.NewLine);
                        }

                        // Note: this does not fix object names with embedded brackets
                        sbSelect.Append("\t[");
                        sbSelect.Append(col.Name);
                        sbSelect.Append(@"]");

                        // Create parameters and where clause from indexed fields
                        if (col.InPrimaryKey == true)
                        {
                            // Parameter columns
                            parm = new StoredProcedureParameter(sp, "@"
                                + col.Name);
                            parm.DataType = col.DataType;
                            parm.DataType.MaximumLength
                                = col.DataType.MaximumLength;
                            sp.Parameters.Add(parm);

                            // Where columns
                            if (sbWhere.Length > 0)
                            {
                                sbWhere.Append(" " + Environment.NewLine + "\tAND ");
                            }

                            // Note: this does not fix object names with embedded brackets
                            sbWhere.Append(@"[");
                            sbWhere.Append(col.Name);
                            sbWhere.Append(@"] = @");
                            sbWhere.Append(col.Name);
                        }
                    }

                    // Put where clause into string
                    if (sbWhere.Length > 0)
                    {
                        sbWhere.Insert(0, @"WHERE ");
                    }

                    sbrStatus.Text = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                        Properties.Resources.Creating, procName);
                    sbSQL.Append("SELECT ");
                    sbSQL.Append(sbSelect);
                    sbSQL.Append(" " + Environment.NewLine + "FROM ");
                    sbSQL.Append(tbl.ToString());
                    sbSQL.Append(" " + Environment.NewLine);
                    sbSQL.Append(sbWhere);
                    sp.TextBody = sbSQL.ToString();
                    sp.Create();
                }
            }
            catch (SmoException ex)
            {
                ExceptionMessageBox emb = new ExceptionMessageBox(ex);
                emb.Show(this);
            }
            finally
            {
                // Clean up.
                sbSQL = null;
                sbSelect = null;
                sbWhere = null;
                sp = null;
                parm = null;
//.........这里部分代码省略.........
开发者ID:rcdosado,项目名称:SMO,代码行数:101,代码来源:CreateStoredProcs.cs

示例3: DropStoredProcedure

        private void DropStoredProcedure(string procName, Schema spSchema)
        {
            Database db = (Database)DatabasesComboBox.SelectedItem;

            if (db.StoredProcedures.Contains(procName, spSchema.Name) == true)
            {
                ScriptTextBox.AppendText(string.Format(
                    System.Globalization.CultureInfo.InvariantCulture,
                    Properties.Resources.DroppingStoredProcedure,
                    spSchema.ToString(), BracketObjectName(procName)) +
                    Environment.NewLine);
                ScrollToBottom();

                // Drop the existing stored procedure
                db.StoredProcedures[procName, spSchema.Name].Drop();
            }
        }
开发者ID:rcdosado,项目名称:SMO,代码行数:17,代码来源:CreateStoredProcs.cs

示例4: Write

 public virtual CodeWriter Write(Schema.Type.Unions type)
 {
     return Write(type.ToString());
 }
开发者ID:GSerjo,项目名称:capnproto-net,代码行数:4,代码来源:CodeWriter.cs


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