本文整理汇总了C#中System.Data.DataColumn.Select方法的典型用法代码示例。如果您正苦于以下问题:C# DataColumn.Select方法的具体用法?C# DataColumn.Select怎么用?C# DataColumn.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataColumn
的用法示例。
在下文中一共展示了DataColumn.Select方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveDuplicates
public static DataTable RemoveDuplicates(DataTable dt, DataColumn[] keyColumns, string SavePath, string currentMapping)
{
int rowNdx = 0;
var res = new List<DataTable>();
DataTable duplicatesTable = dt.Clone();
var qFields = string.Join(", ", keyColumns.Select(x => "it[\"" + x.ColumnName + "\"] as " + x.ColumnName.Replace(" ","") + ""));
var q = dt.AsEnumerable()
.AsQueryable()
.GroupBy("new(" + qFields + ")", "it")
.Select("new (it as Data)");
var dtemp = dt.Clone();
foreach (dynamic d in q)
{
// dtemp.Rows.Add(d.Data.First().ItemArray());
rowNdx = 0;
foreach (var row in d.Data)
{
if (rowNdx == 0)
{
dtemp.Rows.Add(row.ItemArray);
}
else
{
duplicatesTable.Rows.Add(row.ItemArray);
}
rowNdx++;
}
}
string newFileName = string.Format("{0}{1}", "test", rowNdx);
FileSaveHelper.ExportDataTable(duplicatesTable, string.Format("{0}\\{1}", SavePath, currentMapping + "_Duplicates.xlsx"));
return dtemp;
//while (rowNdx < tbl.Rows.Count - 1)
//{
// DataRow[] dups = FindDups(tbl, rowNdx, keyColumns);
// if (dups.Length > 0)
// {
// foreach (DataRow dup in dups)
// {
// duplicatesTable.ImportRow(dup);
// tbl.Rows.Remove(dup);
// }
// tbl.Rows.Add(dups.FirstOrDefault());
// }
// else
// {
// rowNdx++;
// }
//}
// return duplicatesTable;
}
示例2: UpdateFeaturesAction
private DataTable UpdateFeaturesAction(DataColumn[] updateColumns,
object[] updateValues, DataTable historyTable)
{
if (!TableExists(_selName))
throw new Exception("Error selecting update features from MapInfo layer.");
//---------------------------------------------------------------------
// QUERY: KI106 (Shape area and length values)
// Should this include updates for the geom1 and geom2 columns automatically?
//---------------------------------------------------------------------
// update selection
_mapInfoApp.Do(String.Format("Update {0} Set {1}", _selName,
String.Join(",", updateColumns.Select((c, index) => String.Format("{0} = {1}",
GetFieldName(_hluLayerStructure.Columns[c.ColumnName].Ordinal),
QuoteValue(updateValues[index]))).ToArray())));
if (!CommitChanges())
return null;
else
return historyTable;
}
示例3: UpdateFeaturesAction
private DataTable UpdateFeaturesAction(DataColumn[] updateColumns,
object[] updateValues, DataTable historyTable)
{
if (String.IsNullOrEmpty(_selName) || !TableExists(_selName))
throw new Exception("Error selecting update features from MapInfo layer.");
if (String.IsNullOrEmpty(_selName)) return null;
// update selection
_mapInfoApp.Do(String.Format("Update {0} Set {1}", _selName,
String.Join(",", updateColumns.Select((c, index) => String.Format("{0} = {1}",
GetFieldName(_hluLayerStructure.Columns[c.ColumnName].Ordinal),
QuoteValue(updateValues[index]))).ToArray())));
if (!CommitChanges())
return null;
else
return historyTable;
}
示例4: FromList
public string FromList(bool includeFrom, DataColumn[] targetColumns,
bool quoteIdentifiers, ref List<SqlFilterCondition> whereClause, out bool additionalTables)
{
DataTable[] colTables = targetColumns.Select(c => c.Table).Distinct().ToArray();
var whereTables = whereClause.Select(con => con.Table).Distinct().Where(t => !colTables.Contains(t));
int numTables = colTables.Length;
colTables = colTables.Concat(whereTables).ToArray();
additionalTables = colTables.Length > numTables;
whereClause = JoinClause(colTables).Concat(whereClause).ToList();
return FromList(includeFrom, quoteIdentifiers, colTables.Select(t => t.TableName).ToArray());
}