C# DataRow Empty-check

后端 未结 11 1125
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-15 05:13

I got this:

 DataTable dtEntity = CreateDataTable();
 drEntity = dtEntity.NewRow();

Then I add data to the row (or not). Lots of code, real

11条回答
  •  太阳男子
    2020-12-15 05:48

    To delete null and also empty entries Try this

      foreach (var column in drEntitity.Columns.Cast().ToArray())
                {
                    if (drEntitity.AsEnumerable().All(dr => dr.IsNull(column) | string.IsNullOrEmpty( dr[column].ToString())))
                        drEntitity.Columns.Remove(column);
                }
    

提交回复
热议问题