You first check for Count == 0
, doesn't sound right, I guess you need the opposite check. You should use Any
or Count() > 0
check, Like:
if (columns.Any()) //Or columns.Count() > 0
{
var formattedList = columns
.Select(d => null != d
? d.Value.ToString("MMM dd, yyyy")
: string.Empty) // this is just one example to handle null
.ToList();
return formattedList;<-- return this if there is a BreadCrumbID (columns would have a row)
}
else
{
return "In Progress";<--- there was no BreadCrumbID (columns would have 0 rows)
}
You have to convert your List to string, in order for your method to return a string.