Source
foreach (var item in searchFilterItems)
{
if (item.Rows == null || item.Rows.Count <= 0) continue;
foreach (var child in item.Rows)
{
if (child == null || !child.IsSelected) continue;
var newItem = new SearchConditionItem
{
AuditLocationId = item.Id,
Id = child.Id
};
returnList.Add(newItem);
}
}
Target
returnList.AddRange(from item in searchFilterItems
where item.Rows != null && item.Rows.Count > 0
from child in item.Rows
where child != null && child.IsSelected
select new SearchConditionItem
{
AuditLocationId = item.Id,
Id = child.Id
});