I know you can look at the row.count or tables.count, but are there other ways to tell if a dataset is empty?
I have created a small static util class just for that purpose
Below code should read like an English sentence.
public static bool DataSetIsEmpty(DataSet ds)
{
return !DataTableExists(ds) && !DataRowExists(ds.Tables[0].Rows);
}
public static bool DataTableExists(DataSet ds)
{
return ds.Tables != null && ds.Tables.Count > 0;
}
public static bool DataRowExists(DataRowCollection rows)
{
return rows != null && rows.Count > 0;
}
I would just put something like below code and be done with it. Writing a readable code does count.
if (DataAccessUtil.DataSetIsEmpty(ds)) {
return null;
}