本文整理汇总了C#中ITable.Select方法的典型用法代码示例。如果您正苦于以下问题:C# ITable.Select方法的具体用法?C# ITable.Select怎么用?C# ITable.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITable
的用法示例。
在下文中一共展示了ITable.Select方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NaturallyJoinedTable
public NaturallyJoinedTable(ITable left, ITable right)
: base(new[] {left, right})
{
leftRowCount = left.RowCount;
rightRowCount = right.RowCount;
// Build lookup tables for the rows in the parent tables if necessary
// (usually it's not necessary).
// If the left or right tables are simple enumerations, we can optimize
// our access procedure,
leftIsSimpleEnum = (left.GetEnumerator() is SimpleRowEnumerator);
rightIsSimpleEnum = (right.GetEnumerator() is SimpleRowEnumerator);
leftSet = !leftIsSimpleEnum ? left.Select(x => x.RowId.RowNumber).ToList() : null;
rightSet = !rightIsSimpleEnum ? right.Select(x => x.RowId.RowNumber).ToList() : null;
}
示例2: CheckAddConstraintViolations
public static void CheckAddConstraintViolations(this ITransaction transaction, ITable table, ConstraintDeferrability deferred)
{
// Get all the rows in the table
var rows = table.Select(x => x.RowId.RowNumber).ToArray();
// Check the constraints of all the rows in the table.
CheckAddConstraintViolations(transaction, table, rows, deferred);
}
示例3: 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);
}
示例4: Join
public static ITable Join(this ITable table, ITable otherTable, bool quick)
{
ITable outTable;
if (quick) {
// This implementation doesn't materialize the join
outTable = new NaturallyJoinedTable(table, otherTable);
} else {
var tabs = new [] { table, otherTable};
var rowSets = new IList<int>[2];
// Optimized trivial case, if either table has zero rows then result of
// join will contain zero rows also.
if (table.RowCount == 0 || otherTable.RowCount == 0) {
rowSets[0] = new List<int>(0);
rowSets[1] = new List<int>(0);
} else {
// The natural join algorithm.
List<int> thisRowSet = new List<int>();
List<int> tableRowSet = new List<int>();
// Get the set of all rows in the given table.
var tableSelectedSet = otherTable.Select(x => x.RowId.RowNumber).ToList();
int tableSelectedSetSize = tableSelectedSet.Count;
// Join with the set of rows in this table.
var e = table.GetEnumerator();
while (e.MoveNext()) {
int rowIndex = e.Current.RowId.RowNumber;
for (int i = 0; i < tableSelectedSetSize; ++i) {
thisRowSet.Add(rowIndex);
}
tableRowSet.AddRange(tableSelectedSet);
}
// The row sets we are joining from each table.
rowSets[0] = thisRowSet;
rowSets[1] = tableRowSet;
}
// Create the new VirtualTable with the joined tables.
outTable = new VirtualTable(tabs, rowSets);
}
return outTable;
}