How to handle CopyToDataTable() when no rows?

后端 未结 6 1901
滥情空心
滥情空心 2020-12-15 03:21

I have the code:

dt = collListItems.GetDataTable().AsEnumerable()
        .Where(a => Convert.ToString(a[\"Expertise\"]).Contains(expertise) && Co         


        
6条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 04:17

    I think this would be a simpler solution:

    var Adj = (from c in View.AdjustmentsDataSource.AsEnumerable()
                where c["Adjustment"] != System.DBNull.Value
                select c);
    
    if (Adj == null || Adj.Count() == 0)
         return;
    
    DataTable dtChanges = Adj.CopyToDataTable();
    

提交回复
热议问题