本文整理汇总了C#中System.Data.DataColumn.Where方法的典型用法代码示例。如果您正苦于以下问题:C# DataColumn.Where方法的具体用法?C# DataColumn.Where怎么用?C# DataColumn.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataColumn
的用法示例。
在下文中一共展示了DataColumn.Where方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SplitFeaturesLogically
//---------------------------------------------------------------------
// CHANGED: CR10 (Attribute updates for incid subsets)
// The old incid number is passed together with the new incid
// number so that only features belonging to the old incid are
// updated.
public override DataTable SplitFeaturesLogically(string oldIncid, string newIncid, DataColumn[] historyColumns)
{
try
{
if (!TableExists(_selName)) return null;
DataTable historyTable = CreateHistoryTable(_selName, true, historyColumns);
int ixGeom1 = historyColumns.Length;
int ixGeom2 = historyColumns.Length + 1;
//---------------------------------------------------------------------
// FIXED: KI107 (GIS layer column names)
// Ignore case when comparing column names so that GIS layer names may be mixed/upper case
string[] historyColumnNames = historyTable.Columns.Cast<DataColumn>()
.Select(c => _hluFieldNames.ToList().Contains(c.ColumnName, StringComparer.OrdinalIgnoreCase) ?
GetFieldName(_hluLayerStructure.Columns[c.ColumnName].Ordinal).ToLower() : c.ColumnName.ToLower()).ToArray();
var q = historyColumns.Where(c => !_hluFieldNames.ToList().Contains(c.ColumnName, StringComparer.OrdinalIgnoreCase));
string newToidFragmentColumnName = q.Count() == 1 ?
q.ElementAt(0).ColumnName.Replace(GISApp.HistoryAdditionalFieldsDelimiter, String.Empty) : null;
//---------------------------------------------------------------------
int numRows = Int32.Parse(_mapInfoApp.Eval(String.Format("TableInfo({0}, {1})",
_selName, (int)MapInfoConstants.TableInfo.TAB_INFO_NROWS)));
string numFormat = String.Format("D{0}", _hluLayerStructure.toid_fragment_idColumn.MaxLength);
string fetchCommand = String.Format("Fetch Rec {0} From {1}", "{0}", _selName);
string incidCommand = String.Format("{0}.{1}", _selName,
GetFieldName(_hluLayerStructure.incidColumn.Ordinal));
string fragCommand = String.Format("{0}.{1}", _selName,
GetFieldName(_hluLayerStructure.toid_fragment_idColumn.Ordinal));
string toidFragmentCommand = String.Format("{0}.{1}", _selName,
GetFieldName(_hluLayerStructure.toid_fragment_idColumn.Ordinal));
string readCommandTemplate = String.Format("{0}.{1}", _selName, "{0}");
string updateCommandTemplate = String.Format("Update {0} Set {1} = {2} Where RowID = {3}",
_selName, GetFieldName(_hluLayerStructure.incidColumn.Ordinal), QuoteValue(newIncid), "{0}");
for (int i = 1; i <= numRows; i++)
{
_mapInfoApp.RunCommand(String.Format(fetchCommand, i));
//---------------------------------------------------------------------
// CHANGED: CR10 (Attribute updates for incid subsets)
// Only collect the history details and update the incid number if
// the each feature belongs to the old incid.
if (_mapInfoApp.Eval(incidCommand) == oldIncid)
{
CollectHistory(ixGeom1, ixGeom2, readCommandTemplate, historyColumnNames, ref historyTable);
if (!String.IsNullOrEmpty(newToidFragmentColumnName))
historyTable.Rows[historyTable.Rows.Count - 1][newToidFragmentColumnName] = _mapInfoApp.Eval(fragCommand);
_mapInfoApp.Do(String.Format(updateCommandTemplate, i));
}
//---------------------------------------------------------------------
}
if ((historyTable != null) && !CommitChanges())
historyTable = null;
return historyTable;
}
catch
{
_mapInfoApp.Do(String.Format("Rollback Table {0}", _hluLayer));
return null;
}
}
示例2: SqlSelect
private DataTable SqlSelect(bool replaceSelection, bool closePreviousSelection, DataColumn[] targetList, string tableName,
bool addGeometryInfo, bool negateWhereClause, List<SqlFilterCondition> whereConds, DataColumn[] orderBy)
{
if ((_mapInfoApp == null) || (targetList == null) || (targetList.Length == 0))
return new DataTable();
try
{
bool qualifyColumns = false;
bool additionalTables;
DataTable resultTable = null;
StringBuilder sbCommandText = new StringBuilder("SELECT ");
sbCommandText.Append(TargetList(targetList, true, true, ref qualifyColumns, out resultTable));
sbCommandText.Append(FromList(true, targetList, true, ref whereConds, out additionalTables));
if (negateWhereClause)
sbCommandText.Append(" WHERE NOT (").Append(WhereClause(false, true, qualifyColumns,
MapWhereClauseFields(_hluLayerStructure, whereConds))).Append(")");
else
sbCommandText.Append(WhereClause(true, true, qualifyColumns,
MapWhereClauseFields(_hluLayerStructure, whereConds)));
if ((orderBy != null) && (orderBy.Length > 0))
{
StringBuilder orderByColNames = orderBy.Where(c => _hluLayerStructure.Columns.Contains(c.ColumnName))
.Aggregate(new StringBuilder(), (sb, c) => sb.Append(",").Append(qualifyColumns ?
QuoteIdentifier(c.Table.TableName) + "." : String.Empty).Append(
QuoteIdentifier(GetFieldName(_hluLayerStructure.Columns[c.ColumnName].Ordinal))));
if (orderByColNames.Length > 0)
sbCommandText.Append(String.Format(" ORDER BY {0}", orderByColNames.Remove(0, 1)));
}
_mapInfoApp.Do(sbCommandText.ToString());
ReadSelectedRows(replaceSelection, closePreviousSelection, qualifyColumns, addGeometryInfo, tableName, ref resultTable);
return resultTable;
}
catch { return null; }
}
示例3: SplitFeaturesLogically
public override DataTable SplitFeaturesLogically(string newIncid, DataColumn[] historyColumns)
{
try
{
if (String.IsNullOrEmpty(_selName) || !TableExists(_selName)) return null;
DataTable historyTable = CreateHistoryTable(_selName, true, historyColumns);
int ixGeom1 = historyColumns.Length;
int ixGeom2 = historyColumns.Length + 1;
string[] historyColumnNames = historyTable.Columns.Cast<DataColumn>()
.Select(c => _hluFieldNames.Contains(c.ColumnName) ?
GetFieldName(_hluLayerStructure.Columns[c.ColumnName].Ordinal) : c.ColumnName).ToArray();
var q = historyColumns.Where(c => !_hluFieldNames.Contains(c.ColumnName));
string newToidFragmentColumnName = q.Count() == 1 ?
q.ElementAt(0).ColumnName.Replace(GISApp.HistoryAdditionalFieldsDelimiter, String.Empty) : null;
int numRows = Int32.Parse(_mapInfoApp.Eval(String.Format("TableInfo({0}, {1})",
_selName, (int)MapInfoConstants.TableInfo.TAB_INFO_NROWS)));
string numFormat = String.Format("D{0}", _hluLayerStructure.toid_fragment_idColumn.MaxLength);
string fetchCommand = String.Format("Fetch Rec {0} From {1}", "{0}", _selName);
string fragCommand = String.Format("{0}.{1}", _selName,
GetFieldName(_hluLayerStructure.toid_fragment_idColumn.Ordinal));
string toidFragmentCommand = String.Format("{0}.{1}", _selName,
GetFieldName(_hluLayerStructure.toid_fragment_idColumn.Ordinal));
string readCommandTemplate = String.Format("{0}.{1}", _selName, "{0}");
string updateCommandTemplate = String.Format("Update {0} Set {1} = {2} Where RowID = {3}",
_selName, GetFieldName(_hluLayerStructure.incidColumn.Ordinal), QuoteValue(newIncid), "{0}");
for (int i = 1; i <= numRows; i++)
{
_mapInfoApp.RunCommand(String.Format(fetchCommand, i));
CollectHistory(ixGeom1, ixGeom2, readCommandTemplate, historyColumnNames, ref historyTable);
if (!String.IsNullOrEmpty(newToidFragmentColumnName))
historyTable.Rows[historyTable.Rows.Count - 1][newToidFragmentColumnName] = _mapInfoApp.Eval(fragCommand);
_mapInfoApp.Do(String.Format(updateCommandTemplate, i));
}
if ((historyTable != null) && !CommitChanges())
historyTable = null;
return historyTable;
}
catch
{
_mapInfoApp.Do(String.Format("Rollback Table {0}", _hluLayer));
return null;
}
}