删除DataTable的指定行(Lambda)

 DataTable dtTcu = GetAllTcuInfoBySdId(sdId);
DataTable dtToesm = GetAllToesmBySdId(sdId); foreach (DataRow row in dtToesm.Rows)
{
int toesmTcuId = ConvertHelper.ToInt32(row["toesm_manager_tcu_id"]); //店主
int shopOaId = ConvertHelper.ToInt32(row["toesm_toes_oa_id"]); var rows = dtTcu.AsEnumerable().Where<DataRow>(c => c.RowState != DataRowState.Deleted && c["tc_cu_shop_oa_id"].ToString() == shopOaId.ToString());
int rowsCount = rows.Count<DataRow>();
if (rows != null)
{
foreach (DataRow row2 in rows)
{
int tcuId = ConvertHelper.ToInt32(row2["tc_cuid"]);
if (tcuId != toesmTcuId)
{
dtTcu.Rows[dtTcu.Rows.IndexOf(row2)].Delete();
}
}
}
} dtTcu.AcceptChanges();
return dtTcu;
c.RowState != DataRowState.Deleted       //不读取已标记未删除的行(必须判断,否则会抛出异常"读取已删除的行........")
dtTcu.AcceptChanges();   //提交
 
上一篇:CentOS 7 Hadoop安装配置


下一篇:linux每日命令(37):top命令