I am new to LINQ. I have a method like this:
public bool IsNullOrEmptyDataTable(DataSet objDataset, int tableNo)
{
if (objDataset != null)
{
if (objDataset.Tables.Count > 0)
{
if (objDataset.Tables[tableNo].Rows.Count > 0)
{
return false;
}
else
{
return true;
}
}
else
{
return true;
}
}
else
{
return true;
}
}
Can anyone rewrite the business logic in LINQ to save lines of code?
The other answers have shown how you can (and should, IMO) do this without LINQ – but they’ve both still got the same problem that your original code does: you’re only checking whether the data set has any tables – it could have fewer than
tableNotables. I would suggest: