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


C# Table.ToString方法代码示例

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


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

示例1: Table_Constructor_Defaults_To_MappingAttributesAttributes

 public void Table_Constructor_Defaults_To_MappingAttributesAttributes()
 {
     var table = new Table<AllTypesEntity>(null);
     Assert.AreEqual(
         @"SELECT BooleanValue, DateTimeValue, DecimalValue, DoubleValue, Int64Value, IntValue, StringValue, UuidValue FROM AllTypesEntity",
         table.ToString());
 }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:7,代码来源:LinqEntryPointsTests.cs

示例2: Table_Constructor_Uses_Provided_Mappings

 public void Table_Constructor_Uses_Provided_Mappings()
 {
     var table = new Table<AllTypesEntity>(null);
     Assert.AreEqual(
         @"SELECT BooleanValue, DateTimeValue, DecimalValue, DoubleValue, Int64Value, IntValue, StringValue, UuidValue FROM AllTypesEntity",
         table.ToString());
     var config = new MappingConfiguration().Define(new Map<AllTypesEntity>().TableName("tbl3"));
     table = new Table<AllTypesEntity>(null, config);
     Assert.AreEqual(@"SELECT BooleanValue, DateTimeValue, DecimalValue, DoubleValue, Int64Value, IntValue, StringValue, UuidValue FROM tbl3",
         table.ToString());
 }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:11,代码来源:LinqEntryPointsTests.cs

示例3: AddTableButton_Click

        private void AddTableButton_Click(object sender, System.EventArgs e)
        {
            Database db;
            Table tbl;
            Column col;
            Index idx;
            Default dflt;
            Cursor csr = null;

            try
            {
                csr = this.Cursor;   // Save the old cursor
                this.Cursor = Cursors.WaitCursor;   // Display the waiting cursor

                // Show the current tables for the selected database
                db = (Database)DatabasesComboBox.SelectedItem;
                if (db.Tables.Contains(TableNameTextBox.Text) == false)
                {
                    // Create an empty string default
                    dflt = db.Defaults["dfltEmptyString"];
                    if (dflt == null)
                    {
                        dflt = new Default(db, "dfltEmptyString");
                        dflt.TextHeader = "CREATE DEFAULT [dbo].[dfltEmptyString] AS ";
                        dflt.TextBody = @"'';";
                        dflt.Create();
                    }

                    // Create a new table object
                    tbl = new Table(db,
                        TableNameTextBox.Text, db.DefaultSchema);

                    // Add the first column
                    col = new Column(tbl, @"Column1", DataType.Int);
                    tbl.Columns.Add(col);
                    col.Nullable = false;
                    col.Identity = true;
                    col.IdentitySeed = 1;
                    col.IdentityIncrement = 1;

                    // Add the primary key index
                    idx = new Index(tbl, @"PK_" + TableNameTextBox.Text);
                    tbl.Indexes.Add(idx);
                    idx.IndexedColumns.Add(new IndexedColumn(idx, col.Name));
                    idx.IsClustered = true;
                    idx.IsUnique = true;
                    idx.IndexKeyType = IndexKeyType.DriPrimaryKey;

                    // Add the second column
                    col = new Column(tbl, @"Column2", DataType.NVarChar(1024));
                    tbl.Columns.Add(col);
                    col.DataType.MaximumLength = 1024;
                    col.AddDefaultConstraint(null); // Use SQL Server default naming
                    col.DefaultConstraint.Text = Properties.Resources.DefaultConstraintText;
                    col.Nullable = false;

                    // Add the third column
                    col = new Column(tbl, @"Column3", DataType.DateTime);
                    tbl.Columns.Add(col);
                    col.Nullable = false;

                    // Create the table
                    tbl.Create();

                    // Refresh list and select the one we just created
                    ShowTables();

                    // Clear selected items
                    TablesComboBox.SelectedIndex = -1;

                    // Find the table just created
                    TablesComboBox.SelectedIndex = TablesComboBox.FindStringExact(tbl.ToString());
                }
                else
                {
                    ExceptionMessageBox emb = new ExceptionMessageBox();
                    emb.Text = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                        Properties.Resources.TableExists, TableNameTextBox.Text);
                    emb.Show(this);
                }
            }
            catch (SmoException ex)
            {
                ExceptionMessageBox emb = new ExceptionMessageBox(ex);
                emb.Show(this);
            }
            finally
            {
                this.Cursor = csr;  // Restore the original cursor
            }
        }
开发者ID:rcdosado,项目名称:SMO,代码行数:91,代码来源:ManageTables.cs

示例4: SetPropertyValue

        /// <summary>
        /// Establish the extended property and associated value
        /// </summary>
        /// <param name="table">table to be updated</param>
        /// <param name="databasePropertyName">extended property</param>
        /// <param name="value">value</param>
        /// <param name="columnName">column</param>
        /// <param name="overwrite">overwrite</param>
        private void SetPropertyValue(Table table, string databasePropertyName, string value, string columnName, bool overwrite)
        {
            Column column = table.Columns[columnName];
            if (column == null)
            {
                throw new Exception(string.Format(Resources.MissingColumnException, table.ToString(), columnName));
            }

            SetPropertyValue(table, databasePropertyName, value, column, overwrite);
        }
开发者ID:wendy321,项目名称:DataDictionaryCreator,代码行数:18,代码来源:MainForm.cs

示例5: 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

示例6: MatchResult

 public bool MatchResult(Table theExpectedTable)
 {
     string result = myResult.ToString();
     string expected = theExpectedTable.ToString();
     return Trim(result) == Trim(expected);
 }
开发者ID:nhajratw,项目名称:fitsharp,代码行数:6,代码来源:SpecifyFixtureTest.cs

示例7: btnConvert_Click

        private void btnConvert_Click(object sender, EventArgs e)
        {
            SqlConnection cnnSql = new SqlConnection("server=.;Database=" + txtSQLServer.Text + ";trusted_connection=true");
            cnnSql.Open();

            string constr = String.Format("Server={0};Port={1};" + "User Id={2};Password={3};Database={4};", "localhost", "5432", "postgres", "anka", txtPGSQL.Text);

            NpgsqlConnection cnn = new NpgsqlConnection(constr);

            NpgsqlCommand cmd = new NpgsqlCommand();
            cmd.Connection = cnn;
            cmd.CommandText = "SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' AND table_schema = 'public' AND table_name != 'spatial_ref_sys'";
            cnn.Open();

            NpgsqlDataReader rdr = cmd.ExecuteReader();

            List<PostgreTables> tables = new List<PostgreTables>();

            while (rdr.Read())
            {
                PostgreTables tbl = new PostgreTables();
                tbl.Name = rdr["table_name"].ToString();
                tables.Add(tbl);

            }
            rdr.Close();
            DataTable dt = new DataTable();
            List<TableColumns> columns = new List<TableColumns>();
            foreach (var t in tables)
            {

                NpgsqlCommand cmdColumns = new NpgsqlCommand();
                cmdColumns.Connection = cnn;
                cmdColumns.CommandText = "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME [email protected]_name";
                cmdColumns.Parameters.AddWithValue("@table_name", t.Name);

                NpgsqlDataReader rdr2 = cmdColumns.ExecuteReader();
                while (rdr2.Read())
                {
                    TableColumns clm = new TableColumns();

                    clm.Name = rdr2["COLUMN_NAME"].ToString();
                    clm.DataType = rdr2["DATA_TYPE"].ToString();
                    if (clm.DataType.Contains("character"))
                    {
                        clm.MaxLength = Convert.ToInt32(rdr2["character_maximum_length"]);
                    }

                    clm.TableName = t.Name;
                    columns.Add(clm);
                }
                rdr2.Close();

            }

            dataGridView1.DataSource = columns;

            Server s = new Server(@".");

            Database d = s.Databases[txtSQLServer.Text];
            List<TableColumns> clmSql = new List<TableColumns>();
            foreach (var t in tables)
            {

                Table tb = new Table(d, t.Name);
                NpgsqlDataAdapter da = new NpgsqlDataAdapter("select * from " + t.Name + "", cnn);

                DataTable dtb = new DataTable();
                da.Fill(dtb);
                dataGridView2.DataSource = dtb;
                TableColumns cl = new TableColumns();

                foreach (var c in columns)
                {

                    if (c.TableName == t.Name)
                    {

                        SqlConnection con = new SqlConnection("Server=.;Database=" + txtSQLServer.Text + ";trusted_connection=true");
                        con.Open();

                        Column clmn = new Column(tb, c.Name);
                        cl.Name = clmn.Name;
                        cl.TableName = tb.ToString();

                        if (c.DataType == "double precision")
                        {
                            clmn.DataType = Microsoft.SqlServer.Management.Smo.DataType.Float;
                            tb.Columns.Add(clmn);
                            cl.DataType = clmn.DataType.ToString();
                        }
                        else if (c.DataType.Contains("character"))
                        {

                            if (c.MaxLength <= 255)
                            {
                                clmn.DataType = Microsoft.SqlServer.Management.Smo.DataType.VarChar(c.MaxLength);
                            }
                            else
                            {
//.........这里部分代码省略.........
开发者ID:htcnryrlky,项目名称:Converter,代码行数:101,代码来源:Form1.cs


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