本文整理汇总了C#中ITable.IndexOfColumn方法的典型用法代码示例。如果您正苦于以下问题:C# ITable.IndexOfColumn方法的具体用法?C# ITable.IndexOfColumn怎么用?C# ITable.IndexOfColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITable
的用法示例。
在下文中一共展示了ITable.IndexOfColumn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
public static int Delete(this IMutableTable table, ITable other, int limit)
{
List<int> rowSet = new List<int>(other.RowCount);
var e = other.GetEnumerator();
while (e.MoveNext()) {
rowSet.Add(e.Current.RowId.RowNumber);
}
// HACKY: Find the first column of this table in the search table. This
// will allow us to generate a row set of only the rows in the search
// table.
int firstColumn = other.IndexOfColumn(table.GetResolvedColumnName(0));
if (firstColumn == -1)
throw new DatabaseSystemException("Search table does not contain any reference to table being deleted from");
// Generate a row set that is in this tables domain.
var rowsToDelete = other.ResolveRows(firstColumn, rowSet, table).ToList();
// row_set may contain duplicate row indices, therefore we must sort so
// any duplicates are grouped and therefore easier to find.
rowSet.Sort();
// If limit less than zero then limit is whole set.
if (limit < 0)
limit = Int32.MaxValue;
// Remove each row in row set in turn. Make sure we don't remove the
// same row index twice.
int len = System.Math.Min(rowsToDelete.Count, limit);
int lastRemoved = -1;
int removeCount = 0;
for (int i = 0; i < len; ++i) {
int toRemove = rowsToDelete[i];
if (toRemove < lastRemoved)
throw new DatabaseSystemException("Internal error: row sorting error or row set not in the range > 0");
if (toRemove != lastRemoved) {
table.RemoveRow(toRemove);
lastRemoved = toRemove;
++removeCount;
}
}
if (removeCount > 0)
// Perform a referential integrity check on any changes to the table.
table.AssertConstraints();
return removeCount;
}
示例2: OuterJoin
public static ITable OuterJoin(this ITable table, ITable rightTable)
{
// Form the row list for right hand table,
var rowList = rightTable.Select(x => x.RowId.RowNumber).ToList();
int colIndex = rightTable.IndexOfColumn(table.GetResolvedColumnName(0));
rowList = rightTable.ResolveRows(colIndex, rowList, table).ToList();
// This row set
var thisTableSet = table.Select(x => x.RowId.RowNumber).ToList();
thisTableSet.Sort();
rowList.Sort();
// Find all rows that are in 'this table' and not in 'right'
List<int> resultList = new List<int>(96);
int size = thisTableSet.Count;
int rowListIndex = 0;
int rowListSize = rowList.Count;
for (int i = 0; i < size; ++i) {
int thisVal = thisTableSet[i];
if (rowListIndex < rowListSize) {
int inVal = rowList[rowListIndex];
if (thisVal < inVal) {
resultList.Add(thisVal);
} else if (thisVal == inVal) {
while (rowListIndex < rowListSize &&
rowList[rowListIndex] == inVal) {
++rowListIndex;
}
} else {
throw new InvalidOperationException("'this_val' > 'in_val'");
}
} else {
resultList.Add(thisVal);
}
}
// Return the new VirtualTable
return new VirtualTable(table, resultList);
}