本文整理汇总了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);
}
}
示例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);
}
}