我正在尝试实现另一个要求,其中我在数据表中有数据,如下所示
DataTable tableold = new DataTable();
tableold.Columns.Add("Dosage", typeof(string));
tableold.Columns.Add("Drug", typeof(string));
tableold.Columns.Add("Patient", typeof(string));
tableold.Columns.Add("Date", typeof(DateTime));
// Here we add five DataRows.
tableold.Rows.Add(#25, "Indocin", "David", DateTime.Now);
tableold.Rows.Add(#50, "Enebrel", "Sam", DateTime.Now);
tableold.Rows.Add(#10, "Hydralazine", "Christoff", DateTime.Now);
tableold.Rows.Add(#21, "Combivent", "Janet", DateTime.Now);
tableold.Rows.Add(#100, "Dilantin", "Melanie", DateTime.Now);
现在我有一个字符串数组,如下所示
string[] values; (which contains {#25, #50, #10} values)
我需要删除tableold(基表)中存在于字符串数组中的值。 (我知道我觉得这很尴尬,但我是新手)
所以我需要更新的数据表(tableold)看起来像这样:
21, "Combivent", "Janet", "10:20:00"
100, "Dilantin", "Melanie", "10:20:00"
如何在c#或LinQ中编写此类查询
请帮忙!感谢
答案 0 :(得分:0)
使用LINQ:
var newRows = tableold.AsEnumerable().Where(r => !values.Contains(r.Field<string>("Dosage")));
if(newRows.Any())
tableold = newRows.CopyToDataTable();
else
tableold = tableold.Clone(); // empty
答案 1 :(得分:0)
问题有点不清楚,我从输出中了解到你要排除一些android {
compileSdkVersion ..
buildToolsVersion ...
defaultConfig {
...
targetSdkVersion ..
multiDexEnabled true
}
}
。您可以使用ids
Linq
选中此demo