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


C# Column.ResetDefaults方法代码示例

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


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

示例1: GetColumns

        private void GetColumns(ITable table)
        {
            Type uniDBType = typeof(SQLServer.UniDbTypes);

            DataRow[] columnRows = connector.Columns.Select(string.Format("TABLE_NAME = '{0}' AND TABLE_SCHEMA = '{1}'", table.Name.Replace("'", "''"), table.Schema));

            foreach (DataRow columnRow in columnRows)
            {
                bool isReadOnly = false;

                if (Slyce.Common.Utility.StringsAreEqual((string)columnRow["DATA_TYPE"], "timestamp", false))
                {
                    isReadOnly = true;
                }
                Column column = new Column();
                column.Name = (string)columnRow["COLUMN_NAME"];
                column.IsUserDefined = false;
                column.Parent = table;
                column.IsIdentity = columnRow["IsIdentity"] is DBNull ? false : (Convert.ToInt32(columnRow["IsIdentity"])) == 1;
                column.OrdinalPosition = Convert.ToInt32(columnRow["ORDINAL_POSITION"]);
                column.IsNullable = Slyce.Common.Utility.StringsAreEqual((string)columnRow["IS_NULLABLE"], "YES", false);
                column.OriginalDataType = (string)columnRow["DATA_TYPE"];
                column.Size = columnRow.IsNull("CHARACTER_MAXIMUM_LENGTH") //|| column.Datatype == "ntext" || column.Datatype == "text" // ntext/text returns useless length
                                ? 0
                                : Convert.ToInt64(columnRow["CHARACTER_MAXIMUM_LENGTH"]);
                column.InPrimaryKey = connector.DoesColumnHaveConstraint(column, "PRIMARY KEY");
                column.IsUnique = connector.DoesColumnHaveConstraint(column, "UNIQUE");
                column.Default = columnRow.IsNull("COLUMN_DEFAULT") ? "" : (string)columnRow["COLUMN_DEFAULT"];
                column.IsReadOnly = isReadOnly;
                column.Precision = columnRow.IsNull("NUMERIC_PRECISION") ? 0 : Convert.ToInt32(columnRow["NUMERIC_PRECISION"]);
                column.Scale = columnRow.IsNull("NUMERIC_SCALE") ? 0 : Convert.ToInt32(columnRow["NUMERIC_SCALE"]);

                column.ResetDefaults();

                table.AddColumn(column);
            }
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:37,代码来源:MySQLDatabaseLoader.cs

示例2: GetColumns

        private void GetColumns(ITable table)
        {
            Type uniDBType = typeof(SQLServer.UniDbTypes);
            string cleanTableName = table.Name.Replace("'", "''");

            if (!connector.ColumnsBySchema.ContainsKey(table.Schema))
                return;

            if (!connector.ColumnsBySchema[table.Schema].ContainsKey(cleanTableName))
                return;

            List<DataRow> columnRows = connector.ColumnsBySchema[table.Schema][cleanTableName];

            foreach (DataRow columnRow in columnRows)
            {
                bool isReadOnly = false;

                if (Slyce.Common.Utility.StringsAreEqual((string)columnRow["DATA_TYPE"], "timestamp", false))
                {
                    isReadOnly = true;
                }
                Column column = new Column();
                column.Name = (string)columnRow["COLUMN_NAME"];
                column.IsUserDefined = false;
                column.Parent = table;
                column.IsIdentity = columnRow["IsIdentity"] is DBNull ? false : (Convert.ToInt32(columnRow["IsIdentity"])) == 1;
                column.OrdinalPosition = Convert.ToInt32(columnRow["ORDINAL_POSITION"]);
                column.IsNullable = ((string)columnRow["IS_NULLABLE"]).StartsWith("Y", StringComparison.InvariantCultureIgnoreCase);
                column.Precision = columnRow.IsNull("NUMERIC_PRECISION") ? 0 : Convert.ToInt32(columnRow["NUMERIC_PRECISION"]);
                column.Scale = columnRow.IsNull("NUMERIC_SCALE") ? 0 : Convert.ToInt32(columnRow["NUMERIC_SCALE"]);
                column.OriginalDataType = (string)columnRow["DATA_TYPE"];
                column.Size = columnRow.IsNull("CHARACTER_MAXIMUM_LENGTH") //|| column.Datatype == "ntext" || column.Datatype == "text" // ntext/text returns useless length
                                ? 0
                                : Convert.ToInt64(columnRow["CHARACTER_MAXIMUM_LENGTH"]);
                column.InPrimaryKey = connector.DoesColumnHaveConstraint(column, "PRIMARY KEY");
                column.IsUnique = connector.DoesColumnHaveConstraint(column, "UNIQUE");
                column.Default = columnRow.IsNull("COLUMN_DEFAULT") ? "" : (string)columnRow["COLUMN_DEFAULT"];
                column.IsReadOnly = isReadOnly;

                column.ResetDefaults();

                table.AddColumn(column);
            }
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:44,代码来源:OracleDatabaseLoader.cs


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