public static IEnumerable<T> ToRoot<T>(
T item, Func<T, T> selector)
{
if (Equals(item, default(T))) yield break;
yield return item;
foreach (var x in ToRoot(selector(item), selector))
yield return x;
}
And how to use it:
static IEnumerable<int> CreateList(ProductDataSet.ProductRow row)
{
return ToRoot(row, x => x.ProductRowParent).Select(x => x.ProductId);
}
No comments:
Post a Comment