本文整理汇总了C#中Index.ResetDefaults方法的典型用法代码示例。如果您正苦于以下问题:C# Index.ResetDefaults方法的具体用法?C# Index.ResetDefaults怎么用?C# Index.ResetDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index.ResetDefaults方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTableConstraintIndexes
internal void GetTableConstraintIndexes(Table table)
{
DataRow[] indexRows = connector.Indexes.Select(string.Format("TABLE_NAME = '{0}' AND TABLE_SCHEMA = '{1}'", table.Name.Replace("'", "''"), table.Schema));
for (int i = 0; i < indexRows.Length; i++)
{
DataRow indexRow = indexRows[i];
DatabaseIndexType indexType = GetIndexType(indexRow["CONSTRAINT_TYPE"].ToString());
var indexColumnRows = new List<DataRow>();
indexColumnRows.AddRange(connector.Columns.Select(string.Format("TABLE_NAME = '{0}' AND TABLE_SCHEMA = '{1}' AND COLUMN_NAME = '{2}'", table.Name.Replace("'", "''"), table.Schema, indexRow["COLUMN_NAME"])));
while ((i < indexRows.Length - 1) && (string)indexRows[i + 1]["TABLE_NAME"] == table.Name && (string)indexRows[i + 1]["INDEX_NAME"] == (string)indexRow["INDEX_NAME"])
{
i++;
indexRow = indexRows[i];
indexColumnRows.AddRange(connector.Columns.Select(string.Format("TABLE_NAME = '{0}' AND TABLE_SCHEMA = '{1}' AND COLUMN_NAME = '{2}'", table.Name.Replace("'", "''"), table.Schema, indexRow["COLUMN_NAME"])));
}
bool isUnique = (int)indexRow["IS_UNIQUE"] == 1;
bool isClustered = Convert.ToInt32(indexRow["IS_CLUSTERED"]) == 1;
Index index = new Index
{
Name = indexRow["INDEX_NAME"].ToString(),
IsUserDefined = false,
IndexType = indexType,
Parent = table,
IsUnique = isUnique,
IsClustered = isClustered
};
// Fill Columns
foreach (DataRow indexColumnRow in indexColumnRows)
{
var column = index.AddColumn((string)indexColumnRow["COLUMN_NAME"]);
if (index.IsUnique && indexColumnRows.Count == 1)
{
// Columns are only unique if the index has one column
column.IsUnique = true;
}
}
index.ResetDefaults();
table.AddIndex(index);
}
}
示例2: GetUniqueIndexes
private void GetUniqueIndexes(Table table)
{
DataRow[] indexRows = connector.GetUniqueIndexes().Select(string.Format("TABLE_NAME = '{0}' AND TABLE_SCHEMA = '{1}'", table.Name.Replace("'", "''"), table.Schema));
for (int i = 0; i < indexRows.Length; i++)
{
DataRow indexRow = indexRows[i];
Index index = new Index
{
Name = (string)indexRow["INDEX_NAME"],
IsUserDefined = false,
IsUnique = true,
IsClustered = (long)indexRow["IS_CLUSTERED"] == 1,
IndexType = DatabaseIndexType.Unique,
Parent = table
};
List<DataRow> indexColumnRows = new List<DataRow>();
indexColumnRows.AddRange(connector.Columns.Select(string.Format("TABLE_NAME = '{0}' AND TABLE_SCHEMA = '{1}' AND COLUMN_NAME = '{2}'", table.Name.Replace("'", "''"), table.Schema, indexRow["COLUMN_NAME"])));
while ((i < indexRows.Length - 1) && (string)indexRows[i + 1]["TABLE_NAME"] == table.Name && (string)indexRows[i + 1]["INDEX_NAME"] == (string)indexRow["INDEX_NAME"])
{
i++;
indexRow = indexRows[i];
indexColumnRows.AddRange(connector.Columns.Select(string.Format("TABLE_NAME = '{0}' AND TABLE_SCHEMA = '{1}' AND COLUMN_NAME = '{2}'", table.Name.Replace("'", "''"), table.Schema, indexRow["COLUMN_NAME"])));
}
// Fill Columns
foreach (DataRow indexColumnRow in indexColumnRows)
{
var column = index.AddColumn((string)indexColumnRow["COLUMN_NAME"]);
if (index.IsUnique && indexColumnRows.Count == 1)
{
// Columns are only unique if the index has one column
column.IsUnique = true;
}
}
index.ResetDefaults();
table.AddIndex(index);
}
}
示例3: GetUniqueIndexes
private void GetUniqueIndexes(Table table)
{
List<DataRow> indexRows = connector.GetIndexRows(table.Schema, table.Name.Replace("'", "''"));
for (int i = 0; i < indexRows.Count; i++)
{
DataRow indexRow = indexRows[i];
Index index = new Index
{
Name = (string)indexRow["INDEX_NAME"],
IsUserDefined = false,
IsUnique = true,
IsClustered = Convert.ToInt32(indexRow["IS_CLUSTERED"]) == 1,
IndexType = DatabaseIndexType.Unique,
Parent = table
};
List<DataRow> indexColumnRows = new List<DataRow>();
indexColumnRows.AddRange(connector.ColumnsBySchema[table.Schema][table.Name.Replace("'", "''")].Where(c => c[OrdColumn].ToString() == indexRow["COLUMN_NAME"].ToString()));
while ((i < indexRows.Count - 1) && (string)indexRows[i + 1]["TABLE_NAME"] == table.Name && (string)indexRows[i + 1]["INDEX_NAME"] == (string)indexRow["INDEX_NAME"])
{
i++;
indexRow = indexRows[i];
indexColumnRows.AddRange(connector.ColumnsBySchema[table.Schema][table.Name.Replace("'", "''")].Where(c => c[OrdColumn].ToString() == indexRow["COLUMN_NAME"]));
}
// Fill Columns
foreach (DataRow indexColumnRow in indexColumnRows)
{
var column = index.AddColumn((string)indexColumnRow["COLUMN_NAME"]);
if (index.IsUnique && indexColumnRows.Count == 1)
{
// Columns are only unique if the index has one column
column.IsUnique = true;
}
}
index.ResetDefaults();
table.AddIndex(index);
}
}