我有一个具有TransactionID列的DataRow's集合-我正在尝试过滤出TransactionID列表中没有匹配值的DataRow's
List<int?> IDs = _sqlResultsRaw.AsEnumerable()
.Select(x => x.Field<int?>("TransactionID")).ToList();
List<int?> pIDs = _sqlResultsRaw.AsEnumerable()
.Select(x => x.Field<int?>("ParentTransactionID")).ToList();
List<int?> IDsToKeep = IDs.Except(pIDs).ToList();
我想创建一个DataRows集合,该集合具有与IDsToKeep匹配的值。如果TransactionID不在IDsToKeep中,我想将其删除
答案 0 :(得分:0)
EnumerableRowCollection<DataRow> val = _sqlResultsRaw.AsEnumerable()
.Where(x => IDsToKeep.Contains((int)x["TransactionID"]));